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. javascript - angular左右滑动如何切换路由状态,????2. jupyter-notebook - Mac下启动jupyter notebook后没有Python的选项?3. javascript - 求一款靠谱点的移动端图片查看器插件,老司机速进!4. 这是什么情况???5. 数据库创建失败6. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?7. android自带时钟应用的这个效果是怎么做的8. css3的transform问题9. javascript - 如何在外部点击,跳转到网页后,显示指定的模块。10. 使用未定义的常量user_id-假定为“user_id”

网公网安备