Question

Error:

I got and error of Resources$NotFoundException in this line setContentView(R.layout.view_pager_and_titles); I already tested many others layout, I just got a working sample and tried to change the layout to the working one, but Always got this error, whatever I do.

I am using SlidingMenu, ViewPagerIndicator and 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)
Was it helpful?

Solution

You can either use the search function in eclipse, search for

"0x7f040060"


or go to

projectfolder/gen/path/R.java that contains your resources.

You'll find something like this:

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.

If it's under drawable then I'm afraid try to replace that image file

It'll take you to your resource in code.

Hope these might help you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top