So I've searched allot about navigation drawers here, and when I was pointed to a tutorial from an answer in another persons question. I did so.
I successfully managed to create and style the nav drawer to my liking. But now I've been searching tirelessly on how I can launcher activities from the navigation drawer. I've managed to get some code into the the MainActivity but upon clicking the item it does not launch anything? All activities are define in the Manifest. I decided to use Toasts as a trail and error, still no luck.
here's my code for nav drawer, and launch activity.
// Drawer Activity
// Get list items from strings.xml
drawerListViewItems = getResources().getStringArray(R.array.items);
// Get ListView defined in activity_main.xml
drawerListView = (ListView) findViewById(R.id.left_drawer);
// Set the adapter for the list view
drawerListView.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_listview_item, drawerListViewItems));
// Run Activity from drawer
drawerListView.setOnItemClickListener(new DrawerItemClickListener());
And this is my DrawerItemClickListener method
private class DrawerItemClickListener implements ListView.OnItemClickListener {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
Intent a = new Intent(this, AppInfo.class);
startActivity(a);
break;
case 1:
Intent b = new Intent(getBaseContext(), WelcomeActivity.class);
startActivity(b);
}
}
}