Error: FATAL EXCEPTION: main Process: com.example.mustngo.newsp, PID: 1713 android.view.InflateException: Binary XML file line # 2: Error inflating class android.widget.TextView

public abstract class SingleFragmentActivity extends FragmentActivity{ protected abstract Fragment createFragment(); private String[] mPlanetTitles; private DrawerLayout mDrawerLayout; private ListView mDrawerList; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.drawer_layout); mPlanetTitles = getResources().getStringArray(R.array.screen_array); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); // Set the adapter for the list view mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item,mPlanetTitles)); // Set the list's click listener // mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragmentContainer); if (fragment == null){ fragment = createFragment(); fm.beginTransaction().add(R.id.fragmentContainer, fragment).commit(); } } } 

drawer_layout.xml

 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer" > <include layout="@layout/activity_fragment"/> <!-- The navigation drawer --> <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/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/activated_background" android:gravity="center_vertical" android:minHeight="?attr/listPreferredItemHeightSmall" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="test" android:textColor="@color/colorAccent"/> 

    1 answer 1

    You have an error in the layout of the list item on the second line. There you have id . And since you are using a system adapter, most likely the ID should be assigned a similar system markup. Those. try changing it to

     @android:id/text1 //или @android:id/text 

    If it does not help, try system markup instead of yours -

     android.R.layout.simple_list_item 
    • YuriSPb, thank you very much for the comment. I fixed it in the program, but the error remained the same. Also corrected the code in question. - mustango
    • @mustango, I do not see fixes. If it didn't help, try putting your system markup in place of yours - android.R.layout.simple_list_item - JuriySPb
    • one
      YuriiSPb, thanks again. Corrected with the last remarks, everything works with system marking. This issue has been resolved. - mustango