diff --git a/android-navigation-drawer/AndroidManifest.xml b/android-navigation-drawer/AndroidManifest.xml new file mode 100644 index 0000000..61e4d8f --- /dev/null +++ b/android-navigation-drawer/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/android-navigation-drawer/ic_launcher-web.png b/android-navigation-drawer/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/android-navigation-drawer/ic_launcher-web.png differ diff --git a/android-navigation-drawer/res/drawable-hdpi/drawer_shadow.9.png b/android-navigation-drawer/res/drawable-hdpi/drawer_shadow.9.png new file mode 100644 index 0000000..224cc4f Binary files /dev/null and b/android-navigation-drawer/res/drawable-hdpi/drawer_shadow.9.png differ diff --git a/android-navigation-drawer/res/drawable-hdpi/ic_action_search.png b/android-navigation-drawer/res/drawable-hdpi/ic_action_search.png new file mode 100644 index 0000000..f12e005 Binary files /dev/null and b/android-navigation-drawer/res/drawable-hdpi/ic_action_search.png differ diff --git a/android-navigation-drawer/res/drawable-hdpi/ic_drawer.png b/android-navigation-drawer/res/drawable-hdpi/ic_drawer.png new file mode 100644 index 0000000..ff7b1de Binary files /dev/null and b/android-navigation-drawer/res/drawable-hdpi/ic_drawer.png differ diff --git a/android-navigation-drawer/res/drawable-hdpi/ic_launcher.png b/android-navigation-drawer/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..288b665 Binary files /dev/null and b/android-navigation-drawer/res/drawable-hdpi/ic_launcher.png differ diff --git a/android-navigation-drawer/res/layout/activity_main.xml b/android-navigation-drawer/res/layout/activity_main.xml new file mode 100644 index 0000000..1c5e121 --- /dev/null +++ b/android-navigation-drawer/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android-navigation-drawer/res/layout/drawer_listview_item.xml b/android-navigation-drawer/res/layout/drawer_listview_item.xml new file mode 100644 index 0000000..6bc62b2 --- /dev/null +++ b/android-navigation-drawer/res/layout/drawer_listview_item.xml @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/android-navigation-drawer/res/menu/main.xml b/android-navigation-drawer/res/menu/main.xml new file mode 100644 index 0000000..04b3097 --- /dev/null +++ b/android-navigation-drawer/res/menu/main.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/android-navigation-drawer/res/values/dimens.xml b/android-navigation-drawer/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/android-navigation-drawer/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/android-navigation-drawer/res/values/strings.xml b/android-navigation-drawer/res/values/strings.xml new file mode 100644 index 0000000..537e62c --- /dev/null +++ b/android-navigation-drawer/res/values/strings.xml @@ -0,0 +1,19 @@ + + + + App + Settings + Hello world! + + + Item 1 + Item 2 + Item 3 + Item 4 + Item 5 + Item 6 + + + Open navigation drawer + Close navigation drawer + diff --git a/android-navigation-drawer/res/values/styles.xml b/android-navigation-drawer/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/android-navigation-drawer/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/android-navigation-drawer/src/com/hmkcode/android/MainActivity.java b/android-navigation-drawer/src/com/hmkcode/android/MainActivity.java new file mode 100644 index 0000000..7b51be8 --- /dev/null +++ b/android-navigation-drawer/src/com/hmkcode/android/MainActivity.java @@ -0,0 +1,75 @@ +package com.hmkcode.android; + +import android.os.Bundle; +import android.app.Activity; +import android.content.res.Configuration; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.view.GravityCompat; +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; +import android.widget.ListView; + +public class MainActivity extends Activity { + + private String[] drawerListViewItems; + private DrawerLayout drawerLayout; + private ListView drawerListView; + private ActionBarDrawerToggle mDrawerToggle; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + // 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(this, + R.layout.drawer_listview_item, drawerListViewItems)); + + // App Icon + drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + + mDrawerToggle = new ActionBarDrawerToggle( + this, /* host Activity */ + drawerLayout, /* DrawerLayout object */ + R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ + R.string.drawer_open, /* "open drawer" description */ + R.string.drawer_close /* "close drawer" description */ + ); + + // Set the drawer toggle as the DrawerListener + drawerLayout.setDrawerListener(mDrawerToggle); + + getActionBar().setDisplayHomeAsUpEnabled(true); + + drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + + + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); + } + + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // TODO Auto-generated method stub + if (mDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + return super.onOptionsItemSelected(item); + } + +}