SlidingMenu - 资源$ NotFoundException

时间:2013-01-02 16:15:16

标签: android android-resources sliding

错误:

我得到了这行setContentView(R.layout.view_pager_and_titles);中的资源$ NotFoundException的错误我已经测试了很多其他布局,我刚刚得到了一个工作样本并尝试将布局更改为工作布局,但总是遇到此错误,无论如何我做。

我正在使用SlidingMenu,ViewPagerIndicator和SherlockActionBar。

SlidingFragmentActivity:

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)

1 个答案:

答案 0 :(得分:1)

你可以在eclipse中使用搜索功能,搜索

  

“0x7f040060”


或转到

  

包含资源的projectfolder / gen / path / R.java。

你会发现这样的事情:

public static final int Someid=0x7f040060; //These Id is cause error. Also check that under which  class these line contains[Either layout or id or watever].Please check twice that "Someid" is properly mentioned R.layout.Someid or R.id.Someid under proper layout or id.

如果它处于drawable之下,那么我恐怕会尝试替换该图像文件

它将带您到代码中的资源。

希望这些可以帮到你:)。