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"/>