android启动activity报android.content.res.Resources$NotFoundException: String resource ID #x12
来源:互联网 发布:武汉哪里有学电子网络 编辑:程序博客网 时间:2024/06/05 08:02
目标是做一个侧滑菜单,源代码如下
package com.app.news;import com.app.fragment.MenuFragment;import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;import android.os.Bundle;import android.support.v4.app.Fragment;import android.view.Menu;import android.view.Window;public class MainActivity extends SlidingFragmentActivity {/* * 1.得到滑动菜单2.设置滑动菜单是在左边出来还是右边出来3.设置滑动此案的出来之后,内容页显示的剩余宽度4.设置滑动菜单的阴影 设置阴影宽度,阴影需要在开始的时候特别暗,慢慢的变淡5.设置阴影的宽度以及滑动菜单的范围 */ @Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setBehindContentView(R.layout.menu); // setContentView(R.layout.activity_main); setContentView(R.layout.content); // setContentView(R.id.content_frame); //使用帧布局动态替换内容 SlidingMenu sMenu=getSlidingMenu(); sMenu.setMode(SlidingMenu.LEFT); sMenu.setBehindWidthRes(R.dimen.slidingmenu_offset); sMenu.setShadowDrawable(R.drawable.shadow); //设置阴影 sMenu.setShadowWidth(R.dimen.shadow_width); sMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); //设置全屏滑动 //创建fragment MenuFragment menuFragment=new MenuFragment(); getSupportFragmentManager(). //获取fragment的管理者 beginTransaction(). //开启事务 replace(R.id.menu_frame, menuFragment,"Menu"). //替换android默认的frame commit(); //提交事务 } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } /* * 方法D * 回调 */ public void switchFragment(Fragment f){ //点击哪个item就替换之前的content_frame(一片空白区域) getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, f).commit(); } }
然后项目运行起来,报了一下错误:
09-22 09:28:47.291: E/AndroidRuntime(4627): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.news/com.app.news.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f05000a type #0x12 is not valid
09-22 09:28:47.291: E/AndroidRuntime(4627): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)09-22 09:28:47.291: E/AndroidRuntime(4627): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528)
09-22 09:28:47.291: E/AndroidRuntime(4627): at android.app.ActivityThread.access$800(ActivityThread.java:169)
09-22 09:28:47.291: E/AndroidRuntime(4627): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
09-22 09:28:47.291: E/AndroidRuntime(4627): at android.os.Handler.dispatchMessage(Handler.java:111)
09-22 09:28:47.291: E/AndroidRuntime(4627): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f05000a type #0x12 is not valid
Unable to start activity ComponentInfo Caused by: android.content.res.Resources$NotFoundException:
最后发现,是setContentView(R.id.content_frame);//使用帧布局动态替换内容
出了问题,应该是
setContentView(R.layout.content);
0 0
- android启动activity报android.content.res.Resources$NotFoundException: String resource ID #x12
- android启动activity报android.content.res.Resources$NotFoundException: String resource ID #0x0
- android:android.content.res.Resources$NotFoundException: String resource ID #..
- android.content.res.Resources$NotFoundException: String resource ID #0x6d
- android.content.res.Resources$NotFoundException:String resource ID #0x86
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x7f050016
- android.content.res.Resources$NotFoundException:String resource ID #0x86
- android.content.res.Resources$NotFoundException:String resource ID #0x446
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x42
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- Android 70道面试题汇总不再愁面试
- [Leetcode] Search for a Range
- 天池阿里音乐流行趋势预测大赛--初赛
- 项目三-体验复杂度(1)两种排序算法的运算时间
- ios 自定义折叠控件 ——UITableView
- android启动activity报android.content.res.Resources$NotFoundException: String resource ID #x12
- 【转载】 Intellj idea 如何设置类头注释和方法注释
- 刷新页面随机改变某段落的文字(js代码)
- dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()的关联 (一)
- 第四周 项目2-长方形面积
- Verilog语法_4(Modelsim自动化仿真)
- mac装win10后快捷键失灵
- ASCII码对照表
- asp 文件下载