如何利用java反射机制取到静态内部类的静态变量? 10
packagecom.android.menuapp;publicfinalclassR{publicstaticfinalclassattr{}publicstatic...
package com.android.menuapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int chinesecategory_1=0x7f020000;
}
}
利用反射机制怎样取到drawable 中的静态变量?请各位高手不吝赐教,谢谢 展开
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int chinesecategory_1=0x7f020000;
}
}
利用反射机制怎样取到drawable 中的静态变量?请各位高手不吝赐教,谢谢 展开
1个回答
展开全部
通过 drawable s=new R.drawable(); 可得到drawable对象的实例,有了实例就可取得其内部变量
public final class R{
public static final class attr {
}
public static final class drawable {
public static final int chinesecategory_1=0x7f020000;
}
public static void main(String[] args) {
drawable s=new R.drawable();
int a=s.chinesecategory_1;
}
}
public final class R{
public static final class attr {
}
public static final class drawable {
public static final int chinesecategory_1=0x7f020000;
}
public static void main(String[] args) {
drawable s=new R.drawable();
int a=s.chinesecategory_1;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询