public class MainActivity extends AppCompatActivity { private ListView mDrawerList; private ArrayAdapter<String> mAdapter; ... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDrawerList = (ListView)findViewById(R.id.navList); mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); addDrawerItems(); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Dialog aboutDialog = new Dialog(MainActivity.this); aboutDialog.setContentView(R.layout.about); aboutDialog.setCancelable(true); aboutDialog.show(); } }); } private void addDrawerItems() { String[] osArray = { "Profil bearbeiten", "Ein Problem melden", "Nutzungsbedingungen", "Kontakt", "Über uns" }; mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, osArray); mDrawerList.setAdapter(mAdapter); } }
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.rkcsd.apps.mobile.michaelrohde.kilometerrabatt.MainActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="@dimen/appbar_padding_top" android:theme="@style/AppTheme.AppBarOverlay"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" > ...