本文介绍了资源无法找到,没有标识丢失物品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了看这个问题,但是,它并没有帮助解决我的问题:

  • Resources$NotFoundException:资源不是绘制对象

我用在我的应用程序在旧版本兼容ActionBarSherlock(4.4版本)。我的应用程序运行完美的4.1.2,但它崩溃的2.3.3。该应用程序运行一路攀升至点mDrawerLayout.closeDrawer(mDrawerList); 那么之后崩溃。我想不出是什么原因造成崩溃的旧版本。我有一种感觉,那是因为它试图使用未在该版本存在的但是什么东西,我可以什么用没有查明。有没有人看到任何code,似乎错了吗?

在logcat中的错误:致:android.content.res.Resources $ NotFoundException:资源不是绘制对象(彩色或路径)的TypedValue {T = 0X2 / D = 0x10102fd A = -1}

logcat的错误

  08-15 21:01:04.967:E / AndroidRuntime(789):致命异常:主要
08-15 21:01:04.967:E / AndroidRuntime(789):android.view.InflateException:二进制XML文件中的行#17:错误充气类<未知>
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-15 21:01:04.967:E / AndroidRuntime(789):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.LayoutInflater.inflate(LayoutInflater.java:386)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.AbsListView.obtainView(AbsListView.java:1430)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ListView.makeAndAddView(ListView.java:1745)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ListView.fillDown(ListView.java:670)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ListView.fillFromTop(ListView.java:727)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.ListView.layoutChildren(ListView.java:1598)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.AbsListView.onLayout(AbsListView.java:1260)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:702)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View.layout(View.java:7175)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.os.Handler.dispatchMessage(Handler.java:99)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.os.Looper.loop(Looper.java:123)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.app.ActivityThread.main(ActivityThread.java:3683)
08-15 21:01:04.967:E / AndroidRuntime(789):在java.lang.reflect.Method.invokeNative(本机方法)
08-15 21:01:04.967:E / AndroidRuntime(789):在java.lang.reflect.Method.invoke(Method.java:507)
08-15 21:01:04.967:E / AndroidRuntime(789):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
08-15 21:01:04.967:E / AndroidRuntime(789):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-15 21:01:04.967:E / AndroidRuntime(789):在dalvik.system.NativeStart.main(本机方法)
08-15 21:01:04.967:E / AndroidRuntime(789):由:java.lang.reflect.InvocationTargetException
08-15 21:01:04.967:E / AndroidRuntime(789):在java.lang.reflect.Constructor.constructNative(本机方法)
08-15 21:01:04.967:E / AndroidRuntime(789):在java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-15 21:01:04.967:E / AndroidRuntime(789):35 ...更多
08-15 21:01:04.967:E / AndroidRuntime(789):android.content.res.Resources $ NotFoundException:由造成资源不是绘制对象(彩色或路径)的TypedValue {T = 0X2 / D = 0x10102fd一个= -1}
08-15 21:01:04.967:E / AndroidRuntime(789):在android.content.res.Resources.loadDrawable(Resources.java:1681)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.view.View< INIT>(View.java:1951)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.TextView< INIT>(TextView.java:344)
08-15 21:01:04.967:E / AndroidRuntime(789):在android.widget.TextView< INIT>(TextView.java:337)
08-15 21:01:04.967:E / AndroidRuntime(789):38 ...更多
 

从值文件夹styles.xml:

 <资源>
    <样式名称=AppBaseTheme父=Theme.Sherlock.Light.DarkActionBar>
    < /风格>

    <样式名称=AppTheme父=AppBaseTheme>
    < /风格>
< /资源>
 

的Java文件

 保护无效的onCreate(包savedInstanceState){
        // TODO自动生成方法存根
        setTheme(R.style.Theme_Sherlock);
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);
        Log.d(TAG,设置内容视图);

        mTitle =(字符串)的getTitle();
        ChemTitles = getResources()getStringArray(R.array.chemistrycalcstrings)。
        mDrawerLayout =(DrawerLayout)findViewById(R.id.drawer_layout);
        mDrawerList =(ListView控件)findViewById(R.id.left_drawer);

        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);
        mDrawerList.setAdapter(新ArrayAdapter<字符串>(这一点,
                R.layout.drawer_list_item,ChemTitles));
        mDrawerList.setOnItemClickListener(新DrawerItemClickListener());

        getSupportActionBar()setDisplayHomeAsUpEnabled(真)。
        Log.d(TAG,设置显示首页);
        getSupportActionBar()setHomeButtonEnabled(真)。
        Log.d(TAG设为首页按钮);
        Log.d(TAG,设置ActbarDrawerToggle);
        mDrawerToggle =新ActionBarDrawerToggle(
                本,
                mDrawerLayout,
                R.drawable.ic_drawer,
                R.string.drawer_open,
                R.string.drawer_close
                ){
            公共无效onDrawerClosed(查看视图){
                。getSupportActionBar()的setTitle(mTitle);
                。getSherlock()dispatchInvalidateOptionsMenu();
                Log.d(TAG,抽屉关闭);
            }

            公共无效onDrawerOpened(查看drawerView){
                。getSupportActionBar()的setTitle(mDrawerTitle);
                。getSherlock()dispatchInvalidateOptionsMenu();
                Log.d(TAG,抽屉打开);
            }
        };
        Log.d(TAG,设置ActbarDrawerToggle);
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        Log.d(TAG,设置ActbarDrawerToggle监听器);

        如果(savedInstanceState == NULL){
            选择信息(0);
        }
}

私人无效选择信息(INT位置){

    SherlockFragment FRAG =新TestFrament();
    捆绑的args =新包();
    args.putInt(TestFrament.ITEM_SEL,位置);
    frag.setArguments(参数);
    。getSupportFragmentManager()的BeginTransaction()代替(R.id.content_frame,FRAG).commit();
    mDrawerList.setItemChecked(位置,真正的);
    的setTitle(ChemTitles [位置]);
    mDrawerLayout.closeDrawer(mDrawerList);
}
 

修改/更新

我经历了,并评论了所有涉及到的列表视图 mDrawerList 和应用发射直到有一个工作动作条在抽屉里只是没有列表视图的部分。

布局activity_main.xml

 < android.support.v4.widget.DrawerLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / drawer_layout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

    <! - 为主要内容的视图,该视图下方消耗整个
         使用match_parent在两个方向的可用空间。 - >
    <的LinearLayout
        机器人:ID =@ + ID / content_frame
        机器人:方向=横向
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent/>

    <  - 安卓!layout_gravity =开始告诉DrawerLayout治疗
         此为在左侧的滑动抽屉左到右
         语言和右侧从右到左的语言。
         抽屉中给出DP一个固定的宽度和延伸的整个高度
         该容器。的扎实的背景使用对比
         与内容视图。 - >
    <的ListView
        机器人:ID =@ + ID / left_drawer
        机器人:layout_width =240dp
        机器人:layout_height =match_parent
        机器人:layout_gravity =开始
        机器人:choiceMode =singleChoice
        机器人:分隔=@机器人:彩色/透明
        机器人:dividerHeight =0dp
        机器人:后台=#111/>
< /android.support.v4.widget.DrawerLayout>
 

drawer_list_item.xml

 < TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / text1中
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:textAppearance =机器人:ATTR / textAppearanceListItemSmall
    机器人:重力=center_vertical
    机器人:以下属性来=16DP
    机器人:paddingRight =16DP
    机器人:文字颜色=#FFF
    机器人:背景=机器人:ATTR / activatedBackgroundIndicator
    机器人:=了minHeight:/>中的Andr​​oid ATTR /列表preferredItemHeightSmall?
 

test_fragment_layout.xml

 < TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / fragTextSherlock
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:后台=#FFFFFF
    机器人:重力=中心
    机器人:填充=32dp/>
 

TestFragment.java

 公共类TestFrament扩展SherlockFragment {
    公共静态最后弦乐ITEM_SEL =item_selected;
    私人TextView的fragtv;

    公共TestFrament(){
        需要片段子类//空构造
    }

    @覆盖
    公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,
            捆绑savedInstanceState){
        查看rootView = inflater.inflate(R.layout.test_fragment_layout,集装箱,假);
        INT I = getArguments()调用getInt(ITEM_SEL)。
        fragtv =(TextView中)rootView.findViewById(R.id.fragTextSherlock);
        fragtv.setText(将String.valueOf(一));
        返回rootView;
    }
}
 

解决方案

但问题是,编译器没有告诉我,我用的是不是compatiabiliy的部分项目,在2.3.3中暂不提供。

看行,我不得不删除:

drawer_list_item.xml

 < TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / text1中
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:textAppearance =机器人:ATTR / textAppearanceListItemSmall< -Removed
    机器人:重力=center_vertical
    机器人:以下属性来=16DP
    机器人:paddingRight =16DP
    机器人:文字颜色=#FFF
    机器人:背景=机器人:ATTR / activatedBackgroundIndicator< -Removed
    机器人:=了minHeight:/>中的Andr​​oid ATTR /列表preferredItemHeightSmall? < -Removed
 

I looked at this question however, it did not help solve my problem:

I'm using ActionBarSherlock (version 4.4) within my app for compatibility in older versions. My app runs perfect on 4.1.2 but it crashes on 2.3.3. The app runs all the way up to the point of mDrawerLayout.closeDrawer(mDrawerList); then it crashes after that. I cannot figure out what is causing it to crash on older versions. I have a feeling that it is because it is trying to use something that doesn't exist in that version however, I cannot pinpoint what it is using. Does anyone see any code that seems wrong?

The error in the logcat:Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}

Logcat Error

08-15 21:01:04.967: E/AndroidRuntime(789): FATAL EXCEPTION: main
08-15 21:01:04.967: E/AndroidRuntime(789): android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
08-15 21:01:04.967: E/AndroidRuntime(789):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.AbsListView.obtainView(AbsListView.java:1430)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ListView.makeAndAddView(ListView.java:1745)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ListView.fillDown(ListView.java:670)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ListView.fillFromTop(ListView.java:727)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.ListView.layoutChildren(ListView.java:1598)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.AbsListView.onLayout(AbsListView.java:1260)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:702)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.layout(View.java:7175)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.os.Looper.loop(Looper.java:123)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.app.ActivityThread.main(ActivityThread.java:3683)
08-15 21:01:04.967: E/AndroidRuntime(789):  at java.lang.reflect.Method.invokeNative(Native Method)
08-15 21:01:04.967: E/AndroidRuntime(789):  at java.lang.reflect.Method.invoke(Method.java:507)
08-15 21:01:04.967: E/AndroidRuntime(789):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-15 21:01:04.967: E/AndroidRuntime(789):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-15 21:01:04.967: E/AndroidRuntime(789):  at dalvik.system.NativeStart.main(Native Method)
08-15 21:01:04.967: E/AndroidRuntime(789): Caused by: java.lang.reflect.InvocationTargetException
08-15 21:01:04.967: E/AndroidRuntime(789):  at java.lang.reflect.Constructor.constructNative(Native Method)
08-15 21:01:04.967: E/AndroidRuntime(789):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
08-15 21:01:04.967: E/AndroidRuntime(789):  ... 35 more
08-15 21:01:04.967: E/AndroidRuntime(789): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.content.res.Resources.loadDrawable(Resources.java:1681)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.view.View.<init>(View.java:1951)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.TextView.<init>(TextView.java:344)
08-15 21:01:04.967: E/AndroidRuntime(789):  at android.widget.TextView.<init>(TextView.java:337)
08-15 21:01:04.967: E/AndroidRuntime(789):  ... 38 more

styles.xml from values folder:

<resources>
    <style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    </style>

    <style name="AppTheme" parent="AppBaseTheme">
    </style>
</resources>

Java file

protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        setTheme(R.style.Theme_Sherlock);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d(TAG,"Set Content View");

        mTitle = (String) getTitle();
        ChemTitles = getResources().getStringArray(R.array.chemistrycalcstrings);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.drawer_list_item, ChemTitles));
        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        Log.d(TAG,"Set Display Home");
        getSupportActionBar().setHomeButtonEnabled(true);
        Log.d(TAG,"Set Home Button");
        Log.d(TAG,"Setting ActbarDrawerToggle");
        mDrawerToggle = new ActionBarDrawerToggle(
                this,
                mDrawerLayout,
                R.drawable.ic_drawer,
                R.string.drawer_open,
                R.string.drawer_close
                ) {
            public void onDrawerClosed(View view){
                getSupportActionBar().setTitle(mTitle);
                getSherlock().dispatchInvalidateOptionsMenu();
                Log.d(TAG,"Drawer CLosing");
            }

            public void onDrawerOpened(View drawerView){
                getSupportActionBar().setTitle(mDrawerTitle);
                getSherlock().dispatchInvalidateOptionsMenu();
                Log.d(TAG,"Drawer Opening");
            }
        };
        Log.d(TAG,"Set ActbarDrawerToggle");
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        Log.d(TAG,"Set ActbarDrawerToggle Listener");

        if (savedInstanceState == null){
            selectItem(0);
        }
}

private void selectItem(int position){

    SherlockFragment frag = new TestFrament();
    Bundle args = new Bundle();
    args.putInt(TestFrament.ITEM_SEL, position);
    frag.setArguments(args);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, frag).commit();
    mDrawerList.setItemChecked(position, true);
    setTitle(ChemTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

EDIT/UPDATE

I went through and commented out all the parts that involved the listview mDrawerList and the application fired right up with a working actionbar just no listview in the drawer.

Layout activity_main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <LinearLayout
        android:id="@+id/content_frame"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         The drawer is given a fixed width in dp and extends the full height of
         the container. A solid background is used for contrast
         with the content view. -->
    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#111"/>
</android.support.v4.widget.DrawerLayout>

drawer_list_item.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:textColor="#fff"
    android:background="?android:attr/activatedBackgroundIndicator"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"/>

test_fragment_layout.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragTextSherlock"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:gravity="center"
    android:padding="32dp" />

TestFragment.java

public class TestFrament extends SherlockFragment {
    public static final String ITEM_SEL = "item_selected";
    private TextView fragtv;

    public TestFrament() {
        // Empty constructor required for fragment subclasses
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.test_fragment_layout, container, false);
        int i = getArguments().getInt(ITEM_SEL);
        fragtv = (TextView) rootView.findViewById(R.id.fragTextSherlock);
        fragtv.setText(String.valueOf(i));
        return rootView;
    }
}
解决方案

The problem was that the compiler did not tell me that I was using items that were not part of the compatiabiliy and were not avaliable in 2.3.3

Look at the lines I had to remove:

drawer_list_item.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceListItemSmall" <-Removed
    android:gravity="center_vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:textColor="#fff"
    android:background="?android:attr/activatedBackgroundIndicator" <-Removed
    android:minHeight="?android:attr/listPreferredItemHeightSmall"/> <-Removed

这篇关于资源无法找到,没有标识丢失物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 11:48