错误:
我在这一行中遇到了 Resources$NotFoundException 的错误setContentView(R.layout.view_pager_and_titles);
我已经测试了许多其他布局,我刚刚获得了一个工作示例并尝试将布局更改为工作示例,但无论我做什么,总是会出现这个错误。
我正在使用 SlidingMenu、ViewPagerIndicator 和 SherlockActionBar。
滑动片段活动:
public class MainActivity extends SlidingFragmentActivity {
ViewPager mViewPager;
FragmentPagerAdapter mPagerAdapter;
protected ListFragment mFrag;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_pager_and_titles);
// set the Behind View
setBehindContentView(R.layout.menu_frame);
FragmentTransaction t = this.getSupportFragmentManager()
.beginTransaction();
mFrag = new SampleListFragment();
t.replace(R.id.menu_frame, mFrag);
t.commit();
// customize the SlidingMenu
SlidingMenu sm = getSlidingMenu();
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.actionbar_home_width);
setSlidingActionBarEnabled(true);
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager());
final ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayHomeAsUpEnabled(true);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mPagerAdapter);
}
01-02 13:10:28.224: E/AndroidRuntime(899): FATAL EXCEPTION: main
01-02 13:10:28.224: E/AndroidRuntime(899): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.example.nightid.main.BaseSampleActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040060 type #0x12 is not valid
01-02 13:10:28.224: E/AndroidRuntime(899): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.os.Looper.loop(Looper.java:130)
01-02 13:10:28.224: E/AndroidRuntime(899): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-02 13:10:28.224: E/AndroidRuntime(899): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 13:10:28.224: E/AndroidRuntime(899): at java.lang.reflect.Method.invoke(Method.java:507)