|
@@ -1,9 +1,13 @@
|
|
|
package de.tudarmstadt.informatik.hostage.ui2;
|
|
|
|
|
|
+import android.app.ActionBar;
|
|
|
import android.app.Activity;
|
|
|
+import android.content.res.Configuration;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.ActionBarDrawerToggle;
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
@@ -32,6 +36,11 @@ public class MainActivity extends Activity {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_drawer_main);
|
|
|
|
|
|
+ ActionBar actionBar = getActionBar();
|
|
|
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE
|
|
|
+ | ActionBar.DISPLAY_SHOW_HOME
|
|
|
+ | ActionBar.DISPLAY_HOME_AS_UP);
|
|
|
+
|
|
|
mTitle = mDrawerTitle = getTitle();
|
|
|
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
|
|
mDrawerList = (ListView) findViewById(R.id.left_drawer);
|
|
@@ -55,23 +64,59 @@ public class MainActivity extends Activity {
|
|
|
mDrawerToggle = new ActionBarDrawerToggle(
|
|
|
this, /* host Activity */
|
|
|
mDrawerLayout, /* DrawerLayout object */
|
|
|
- R.drawable.ic_launcher, /* nav drawer image to replace 'Up' caret */
|
|
|
+ R.drawable.ic_navigation_drawer, /* nav drawer image to replace 'Up' caret */
|
|
|
R.string.drawer_open, /* "open drawer" description for accessibility */
|
|
|
R.string.drawer_close /* "close drawer" description for accessibility */
|
|
|
) {
|
|
|
public void onDrawerClosed(View view) {
|
|
|
getActionBar().setTitle(mTitle);
|
|
|
- //invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
|
|
|
+ invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
|
|
|
}
|
|
|
|
|
|
public void onDrawerOpened(View drawerView) {
|
|
|
getActionBar().setTitle(mDrawerTitle);
|
|
|
- //invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
|
|
|
+ invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
|
|
|
}
|
|
|
};
|
|
|
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ // toggle nav drawer on selecting action bar app icon/title
|
|
|
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setTitle(CharSequence title) {
|
|
|
+ mTitle = title;
|
|
|
+ getActionBar().setTitle(mTitle);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * When using the ActionBarDrawerToggle, you must call it during
|
|
|
+ * onPostCreate() and onConfigurationChanged()...
|
|
|
+ */
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
+ super.onPostCreate(savedInstanceState);
|
|
|
+ // Sync the toggle state after onRestoreInstanceState has occurred.
|
|
|
+ mDrawerToggle.syncState();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConfigurationChanged(Configuration newConfig) {
|
|
|
+ super.onConfigurationChanged(newConfig);
|
|
|
+ // Pass any configuration change to the drawer toggls
|
|
|
+ mDrawerToggle.onConfigurationChanged(newConfig);
|
|
|
+ }
|
|
|
+
|
|
|
private class DrawerItemClickListener implements ListView.OnItemClickListener {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|