安卓Xposed怎么jquery获取自定义属性类的属性

如何获取自定义类的所有属性 以及属性的类型_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
如何获取自定义类的所有属性 以及属性的类型
我有更好的答案
&;@property(nonatomic ,assign) double _
objc_property_t *properties = class_copyPropertyList(klass, &propertyCount),N;
for (unsigned int i = 0如何获取自定义类的所有属性 以及属性的类型
本帖属于CocoaChina会员发表,Vstate正常输出_float
Tf,N,V__float_double
Td,N,V__double_date
T@&NSDate&; ++i) {
objc_property_t property = properties[i],N;@property(nonatomic ,retain) NSDate * _date,转帖请写明来源和帖子地址题目有点长 直接看代码复制代码@interface AppState : NSObject{
_ i & propertyC获取属性类型}具体的输出如下所示复制代码输出类
state T@&AppState&;
const char * name = property_getName(property);/
* 状态是否正常
BOOL isP/objc/runtime.h&/获取属性名字
const char * attributes = property_getAttributes(property),&;@property(nonatomic ,assign) int
_,V__date_char
Tc;@property(nonatomic ,assign) char _**
* 用户数据
*&#47,V__char前面正常获得了所需的属性名称但是后面的这个串让我怎么获取类别呢?;
NSMutableDictionary * userV}@property(nonatomic ,assign) float _@property(nonatomic ,assign) BOOL isP我通过#import &//@property(nonatomic ,assign) BOOL _passed,N;里面的这样的方式来获取 所有的属性名 以及属性类型复制代码unsigned int propertyCount = 0
资深电脑人
为您推荐:
其他类似问题
自定义的相关知识
换一换
回答问题,赢新手礼包XPOSED如何显示一个类的成员变量_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
XPOSED如何显示一个类的成员变量
我有更好的答案
V__float_double Td,N,V__double_date T@&//NSMutableDictionary * userV}@property(nonatomic ,assign) float _float, &propertyCount);for (unsigned int i = 0; i &lt,assign) BOOL isP我通#import runtime,N; propertyC ++i) {objc_property_t property = properties[i];const char * name = property_getName(property);,&,N,Vstate输_float Tf.h&面式获取 所属性名 及属性类型复制代码unsigned int propertyCount = 0;objc_property_t *properties = class_copyPropertyList(@property(nonatomic ,assign) char _AppState&/获取属性类型}具体输所示复制代码输类 state T@&@property(nonatomic ,assign) double _double何获取自定义类所属性 及属性类型 本帖属于CocoaChina员发表转帖请写明源帖址题目点 直接看代码复制代码@interface AppState : NSObject{BOOL _*** 用户数据*/*** 状态否*/BOOL isP/@property(nonatomic ,retain) NSDate * _NSDate&;@property(@property(nonatomic ,assign) int _获取属性名字const char * attributes = property_getAttributes(property);&#47,assign) BOOL _@property(int _&#47
采纳率:88%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包博客分类:
.net中可以使用Type.GetCustomAttributes获取类上的自定义属性,可以使用PropertyInfo.GetCustomAttributes获取属性信息上的自定义属性。
下面以定义一个简单数据库表的映射实体类来说明相关的使用方法,基于自定义类属性和自定义类中的属性的自定义属性,可以方便的进行类标记和类中属性的标记
创建一个类的自定义属性,用于标识数据库中的表名称,需要继承自Attribute类:
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class TableAttribute : Attribute
private readonly string _TableName = "";
public TableAttribute(string tableName)
this._TableName = tableN
public string TableName
get { return this._TableN }
创建一个属性的自定义属性,用于标识数据库表中字段的名称,需要继承自Attribute类
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public class FieldAttribute : Attribute
private readonly string _FieldName = "";
///数据库的字段名称
private System.Data.DbType _Type = System.Data.DbType.S
///数据库的字段类型
public FieldAttribute(string fieldName)
this._FieldName=fieldN
public FieldAttribute(string fieldName,System.Data.DbType type)
this._FieldName=fieldN
this._Type=
public string FieldName
get { return this._FieldN }
public System.Data.DbType Type
get{return this._T}
创建一个数据实体基类:
public class BaseEntity
public BaseEntity()
/// &summary&
/// 获取表名称
/// &/summary&
/// &returns&&/returns&
public string GetTableName()
Type type = this.GetType();
object[] objs = type.GetCustomAttributes(typeof(TableAttribute), true);
if (objs.Length &= 0)
throw new Exception("实体类没有标识TableAttribute属性");
object obj = objs[0];
TableAttribute ta = (TableAttribute)
return ta.TableN
//获取表名称
/// &summary&
/// 获取数据实体类上的FieldAttribute
/// &/summary&
/// &param name="propertyName"&&/param&
/// &returns&&/returns&
public FieldAttribute GetFieldAttribute(string propertyName)
PropertyInfo field = this.GetType().GetProperty(propertyName);
if (field == null)
throw new Exception("属性名" + propertyName + "不存在");
object[] objs = field.GetCustomAttributes(typeof(FieldAttribute), true);
if (objs.Length &= 0)
throw new Exception("类体属性名" + propertyName + "没有标识FieldAttribute属性");
object obj = objs[0];
FieldAttribute fieldAttribute=(FieldAttribute)
fieldAttribute.FieldValue=field.GetValue(this,null);
return fieldA
创建数据实体
[Table("Wincms_Dictionary")]
///映射到数据库的Wincms_Dictionary表
public class Wincms_Dictionary : BaseEntity
private int _DictionaryId;
public Wincms_Dictionary()
[Field("DictionaryId",DbType.Int32)]
///映射到数据库的Wincms_Dictionary表中的字段
public int DictionaryId
get { return this._DictionaryId; }
this._DictionaryId =
///基于实体类获取实体对应的表名称和字段名称
public class Test
public static void main(string[] args)
Wincms_Dictionary dict=new Wincms_Dictionary();
Console.WriteLine("表名称:"+GetTableName(dict));
Console.WriteLine("字段名称:"+GetFieldName(dict,"DictionaryId"));
Console.Read();
///获取实体表名称
static string GetTableName(BaseEntity entity)
return entity.GetTableName();
///获取实体字段名称
public static string GetFieldName(BaseEntity entity,string propertyName)
FieldAttribute fieldAttribute=entity.GetFieldAttribute(propertyName);
return fieldAttribute.FieldN
输出结果为:
表名称:Wincms_Dictionary
字段名称:DictionaryId
浏览: 50435 次
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'1. reference:参考某一资源ID。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "名称"&
&&&&&&&&&&&&&&&&&& &attr name = "background" format = "reference" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&&& &ImageView
&&&&&&&&&&&&&&&&&&&& android:layout_width = "42dip"
&&&&&&&&&&&&&&&&&&&& android:layout_height = "42dip"
&&&&&&&&&&&&&&&&&&&& android:background = "@drawable/图片ID"
&&&&&&&&&&&&&&&&&&&& /&
2. color:颜色值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "名称"&
&&&&&&&&&&&&&&&&&& &attr name = "textColor" format = "color" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &TextView
&&&&&&&&&&&&&&&&&&&& android:layout_width = "42dip"
&&&&&&&&&&&&&&&&&&&& android:layout_height = "42dip"
&&&&&&&&&&&&&&&&&&&& android:textColor = "#00FF00"
&&&&&&&&&&&&&&&&&&&& /&
3. boolean:布尔值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "名称"&
&&&&&&&&&&&&&&&&&& &attr name = "focusable" format = "boolean" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &Button
&&&&&&&&&&&&&&&&&&& android:layout_width = "42dip"
&&&&&&&&&&&&&&&&&&& android:layout_height = "42dip"
&&&&&&&&&&&&&&&&&&& android:focusable = "true"
&&&&&&&&&&&&&&&&&&& /&
4. dimension:尺寸值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "名称"&
&&&&&&&&&&&&&&&&&& &attr name = "layout_width" format = "dimension" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &Button
&&&&&&&&&&&&&&&&&&& android:layout_width = "42dip"
&&&&&&&&&&&&&&&&&&& android:layout_height = "42dip"
&&&&&&&&&&&&&&&&&&& /&
5. float:浮点值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "AlphaAnimation"&
&&&&&&&&&&&&&&&&&& &attr name = "fromAlpha" format = "float" /&
&&&&&&&&&&&&&&&&&& &attr name = "toAlpha" format = "float" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &alpha
&&&&&&&&&&&&&&&&&& android:fromAlpha = "1.0"
&&&&&&&&&&&&&&&&&& android:toAlpha = "0.7"
&&&&&&&&&&&&&&&&&& /&
6. integer:整型值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "AnimatedRotateDrawable"&
&&&&&&&&&&&&&&&&&& &attr name = "visible" /&
&&&&&&&&&&&&&&&&&& &attr name = "frameDuration" format="integer" /&
&&&&&&&&&&&&&&&&&& &attr name = "framesCount" format="integer" /&
&&&&&&&&&&&&&&&&&& &attr name = "pivotX" /&
&&&&&&&&&&&&&&&&&& &attr name = "pivotY" /&
&&&&&&&&&&&&&&&&&& &attr name = "drawable" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &animated-rotate
&&&&&&&&&&&&&&&&&& xmlns:android = "/apk/res/android"
&&&&&&&&&&&&&&&&&& android:drawable = "@drawable/图片ID"
&&&&&&&&&&&&&&&&&& android:pivotX = "50%"
&&&&&&&&&&&&&&&&&& android:pivotY = "50%"
&&&&&&&&&&&&&&&&&& android:framesCount = "12"
&&&&&&&&&&&&&&&&&& android:frameDuration = "100"
&&&&&&&&&&&&&&&&&& /&
7. string:字符串。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "MapView"&
&&&&&&&&&&&&&&&&&& &attr name = "apiKey" format = "string" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &com.google.android.maps.MapView
&&&&&&&&&&&&&&&&&&& android:layout_width = "fill_parent"
&&&&&&&&&&&&&&&&&&& android:layout_height = "fill_parent"
&&&&&&&&&&&&&&&&&&& android:apiKey = "0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g"
&&&&&&&&&&&&&&&&&&& /&
8. fraction:百分数。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name="RotateDrawable"&
&&&&&&&&&&&&&&&&&& &attr name = "visible" /&
&&&&&&&&&&&&&&&&&& &attr name = "fromDegrees" format = "float" /&
&&&&&&&&&&&&&&&&&& &attr name = "toDegrees" format = "float" /&
&&&&&&&&&&&&&&&&&& &attr name = "pivotX" format = "fraction" /&
&&&&&&&&&&&&&&&&&& &attr name = "pivotY" format = "fraction" /&
&&&&&&&&&&&&&&&&&& &attr name = "drawable" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &rotate
&&&&&&&&&&&&&&&&&& xmlns:android = "/apk/res/android"
  &&&&&&&&&&&& android:interpolator = "@anim/动画ID"
&&&&&&&&&&&&&&&&&& android:fromDegrees = "0"
  &&&&&&&&&&&& android:toDegrees = "360"
&&&&&&&&&&&&&&&&&& android:pivotX = "200%"
&&&&&&&&&&&&&&&&&& android:pivotY = "300%"
  &&&&&&&&&&&& android:duration = "5000"
&&&&&&&&&&&&&&&&&& android:repeatMode = "restart"
&&&&&&&&&&&&&&&&&& android:repeatCount = "infinite"
&&&&&&&&&&&&&&&&&& /&
9. enum:枚举值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name="名称"&
&&&&&&&&&&&&&&&&&& &attr name="orientation"&
&&&&&&&&&&&&&&&&&&&&&&&&& &enum name="horizontal" value="0" /&
&&&&&&&&&&&&&&&&&&&&&&&&& &enum name="vertical" value="1" /&
&&&&&&&&&&&&&&&&&& &/attr&&&&&&&&&&&&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&& &LinearLayout
&&&&&&&&&&&&&&&&&&& xmlns:android = "/apk/res/android"
&&&&&&&&&&&&&&&&&&& android:orientation = "vertical"
&&&&&&&&&&&&&&&&&&& android:layout_width = "fill_parent"
&&&&&&&&&&&&&&&&&&& android:layout_height = "fill_parent"
&&&&&&&&&&&&&&&&&&& &
&&&&&&&&&&& &/LinearLayout&
10. flag:位或运算。
&&&& (1)属性定义:
&&&&&&&&&&&& &declare-styleable name="名称"&
&&&&&&&&&&&&&&&&&&& &attr name="windowSoftInputMode"&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateUnspecified" value = "0" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateUnchanged" value = "1" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateHidden" value = "2" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateAlwaysHidden" value = "3" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateVisible" value = "4" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "stateAlwaysVisible" value = "5" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "adjustUnspecified" value = "0x00" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "adjustResize" value = "0x10" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "adjustPan" value = "0x20" /&
&&&&&&&&&&&&&&&&&&&&&&&&&&& &flag name = "adjustNothing" value = "0x30" /&
&&&&&&&&&&&&&&&&&&&& &/attr&&&&&&&&&
&&&&&&&&&&&& &/declare-styleable&
&&&& (2)属性使用:
&&&&&&&&&&& &activity
&&&&&&&&&&&&&&&&&& android:name = ".StyleAndThemeActivity"
&&&&&&&&&&&&&&&&&& android:label = "@string/app_name"
&&&&&&&&&&&&&&&&&& android:windowSoftInputMode = "stateUnspecified | stateUnchanged | stateHidden"&
&&&&&&&&&&&&&&&&&& &intent-filter&
&&&&&&&&&&&&&&&&&&&&&&&&& &action android:name = "android.intent.action.MAIN" /&
&&&&&&&&&&&&&&&&&&&&&&&&& &category android:name = "android.intent.category.LAUNCHER" /&
&&&&&&&&&&&&&&&&&& &/intent-filter&
&&&&&&&&&&&& &/activity&
&&&& 注意:
&&&& 属性定义时可以指定多种类型值。
&&& (1)属性定义:
&&&&&&&&&&& &declare-styleable name = "名称"&
&&&&&&&&&&&&&&&&&& &attr name = "background" format = "reference|color" /&
&&&&&&&&&&& &/declare-styleable&
&&& (2)属性使用:
&&&&&&&&&&&& &ImageView
&&&&&&&&&&&&&&&&&&&& android:layout_width = "42dip"
&&&&&&&&&&&&&&&&&&&& android:layout_height = "42dip"
&&&&&&&&&&&&&&&&&&&& android:background = "@drawable/图片ID|#00FF00"
&&&&&&&&&&&&&&&&&&&& /&
浏览 15155
huangbo_2020
浏览: 89897 次
来自: 上海
https://www.virtualbox.org/wiki ...
我现在想画一个日历
想根据我给的时间画
java -jar signapk.jar
../../.. ...
用于修改文件git add -i
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'android开发教程之自定义属性用法详解
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了android开发中的自定义属性用法详解,需要的朋友可以参考下
最近项目中经常需要用到自定义控件,因此自定义属性也是经常要用到的,在此说明一下自定义属性的用法:
自定义属性都存在于/value/attr.xml文件中,以如下格式存在。 代码如下:&resource&
&declare-styleable name="自定义属性名称"&
&attr name="属性名称" format="属性种类"/&
&/declare-styleable&
&/resource&
对于自定义属性中的format的值及其含义如下:
format属性值:reference 、color、boolean、dimension、float、integer、string、fraction、enum、flag
1. reference:参考某一资源ID。
(1)属性定义: 代码如下:&declare-styleable name = "名称"&
&& &attr name = "background" format = "reference" /&
&/declare-styleable&
(2)属性使用: 代码如下:&ImageView
android:layout_width="42dip"android:layout_height="42dip"android:background="@drawable/图片ID"/&
2.color:颜色值。
(1)属性定义: 代码如下:&declare-styleablename="名称"&
&attrname="textColor"format="color"/&
&/declare-styleable&
(2)属性使用: 代码如下:&TextViewandroid:layout_width="42dip"android:layout_height="42dip"android:textColor="#00FF00"/&
3.boolean:布尔值。
(1)属性定义: 代码如下:&declare-styleablename="名称"&
&attrname="focusable"format="boolean"/&
&/declare-styleable&
(2)属性使用: 代码如下:&Buttonandroid:layout_width="42dip"android:layout_height="42dip"android:focusable="true"/&
4.dimension:尺寸值。
(1)属性定义: 代码如下:&declare-styleablename="名称"&
&attrname="layout_width"format="dimension"/&
&/declare-styleable&
(2)属性使用: 代码如下:&Buttonandroid:layout_width="42dip"android:layout_height="42dip"/&
5.float:浮点值。
(1)属性定义: 代码如下:&declare-styleablename="AlphaAnimation"&&attrname="fromAlpha"format="float"/&&attrname="toAlpha"format="float"/&&/declare-styleable&
(2)属性使用: 代码如下:&alphaandroid:fromAlpha="1.0"android:toAlpha="0.7"/&
6.integer:整型值。
(1)属性定义: 代码如下:&declare-styleablename="AnimatedRotateDrawable"&&attrname="visible"/&&attrname="frameDuration"format="integer"/&&attrname="framesCount"format="integer"/&&attrname="pivotX"/&&attrname="pivotY"/&&attrname="drawable"/&&/declare-styleable&
(2)属性使用: 代码如下:&animated-rotatexmlns:android="/apk/res/android"android:drawable="@drawable/图片ID"android:pivotX="50%"android:pivotY="50%"android:framesCount="12"android:frameDuration="100"/&
7.string:字符串。
(1)属性定义: 代码如下:&declare-styleablename="MapView"&&attrname="apiKey"format="string"/&&/declare-styleable&
(2)属性使用: 代码如下:&com.google.android.maps.MapViewandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:apiKey="0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g"/&
8.fraction:百分数。
(1)属性定义: 代码如下:&declare-styleablename="RotateDrawable"&&attrname="visible"/&&attrname="fromDegrees"format="float"/&&attrname="toDegrees"format="float"/&&attrname="pivotX"format="fraction"/&&attrname="pivotY"format="fraction"/&&attrname="drawable"/&&/declare-styleable&
(2)属性使用: 代码如下:&rotatexmlns:android="/apk/res/android"  android:interpolator="@anim/动画ID"
android:fromDegrees="0"android:toDegrees="360"
android:pivotX="200%"
android:pivotY="300%"android:duration="5000"
android:repeatMode="restart"
android:repeatCount="infinite"
9.enum:枚举值。
(1)属性定义: 代码如下:&declare-styleablename="名称"&&attrname="orientation"&&enumname="horizontal"value="0"/&&enumname="vertical"value="1"/&&/attr&&/declare-styleable&
(2)属性使用: 代码如下:&LinearLayoutxmlns:android="/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"&&/LinearLayout&
10.flag:位或运算。
(1)属性定义: 代码如下:&declare-styleablename="名称"&&attrname="windowSoftInputMode"&&flagname="stateUnspecified"value="0"/&&flagname="stateUnchanged"value="1"/&&flagname="stateHidden"value="2"/&&flagname="stateAlwaysHidden"value="3"/&&flagname="stateVisible"value="4"/&&flagname="stateAlwaysVisible"value="5"/&&flagname="adjustUnspecified"value="0x00"/&&flagname="adjustResize"value="0x10"/&&flagname="adjustPan"value="0x20"/&&flagname="adjustNothing"value="0x30"/&&/attr&&/declare-styleable&
(2)属性使用: 代码如下:&activityandroid:name=".StyleAndThemeActivity"android:label="@string/app_name"android:windowSoftInputMode="stateUnspecified|stateUnchanged | stateHidden"&&intent-filter&&actionandroid:name="android.intent.action.MAIN"/&&categoryandroid:name="android.intent.category.LAUNCHER"/&&/intent-filter&&/activity&
特别要注意:
属性定义时可以指定多种类型值。
(1)属性定义: 代码如下:&declare-styleablename="名称"&&attrname="background"format="reference|color"/&&/declare-styleable&
(2)属性使用: 代码如下:&ImageViewandroid:layout_width="42dip"android:layout_height="42dip"android:background="@drawable/图片ID|#00FF00"/&
下面说说AttributeSet与TypedArray在自定义控件中的作用:
AttributeSet的作用就是在控件进行初始化的时候,解析布局文件中该控件的属性(keyeg:background)与该值(valueeg:@drawable/icon)的信息封装在AttributeSet中,传递给该控件(View)的构造函数。对于非Android自带的属性,在View类中处理时是无法识别的,因此需要我们自己解析。所以这就要用到另外一个类TypedArray。在AttributeSet中我们有属性名称,有属性值,但是控件如何知道哪个属性代表什么意思呢?这个工作就由TypedArray来做了。TypedArray对象封装了/values/attrs.xml中的styleable里定义的每个属性的类型信息,通过TypedArray我们就可以知道AttributeSet中封装的值到底是干什么的了,从而可以对这些数据进行应用。
AttributeSet就相当于一盒糖,TypedArray就相当于这盒糖上的标签说明,告诉用户每个糖的口味等。这盒糖有什么口味是由用户自己的styleable文件里面的内容来决定的。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具}

我要回帖

更多关于 获取自定义属性 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信