java android getResources()。getIdentifier()
问题似乎是您要转换drawerSelection为小写字母。在R.java文件中很明显,标识符的大小写得以保留。尝试致电:
int panelId = this.getResources().getIdentifier(drawerSelection,'id',getActivity().getPackageName());解决方法
如何从R.获取ID的int id值?当我使用getIdentifier它的正好回报0。
int i = getArguments().getInt(SELECTION_NUMBER); String drawerSelection = getResources().getStringArray(R.array.drawerSelection_array)[i];int panelId = this.getResources().getIdentifier(drawerSelection.toLowerCase(),'id',getActivity().getPackageName());
编辑
Xml
<LinearLayout xmlns:android='http://schemas.android.com/apk/res/android'android:layout_width='match_parent'android:layout_height='match_parent'android:orientation='vertical' ><ListView android: android:layout_width='match_parent' android:layout_height='wrap_content' ></ListView></LinearLayout>
日志
06-10 21:24:30.372: I/System.out(3572): Selection = Bus_Schedules06-10 21:24:30.372: I/System.out(3572): panelId = 0
R.java
public static final class id { public static final int Bus_Schedules=0x7f090004; public static final int basemenu=0x7f090005; public static final int content_frame=0x7f090001; public static final int drawer_layout=0x7f090000; public static final int left_drawer=0x7f090002;
相关文章:
1. Python处理Dict生成json2. (python)关于如何做到按win+R再输入文件文件名就可以运行?3. 想练支付宝对接和微信支付对接开发(Java),好像个人不可以,怎么弄个企业的4. mysql - Sql union 操作5. java - Mybatis 数据库多表关联分页的问题6. 急急急!!!求大神解答网站评论问题,有大神帮帮小弟吗7. javascript - 按钮链接到另一个网址 怎么通过百度统计计算按钮的点击数量8. python - 如何使用websocket在网页上动态示实时数据的折线图?9. python - 请问这两个地方是为什么呢?10. python2.7 - python 正则前瞻 后瞻 无法匹配到正确的内容
