0

错误:

我在这一行中遇到了 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)
4

1 回答 1

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.

如果它处于可绘制状态,那么恐怕会尝试替换该图像文件

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

希望这些可以帮助你:)

于 2013-01-02T18:17:58.653 回答