parent
ec16f3d7d1
commit
90f737a704
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hmkcode.android"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.hmkcode.android.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 171 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
@ -0,0 +1,27 @@
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- The main content view -->
|
||||
<FrameLayout
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
<!-- 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="#666"
|
||||
android:dividerHeight="1dp"
|
||||
android:background="#333"
|
||||
android:paddingLeft="15sp"
|
||||
android:paddingRight="15sp"
|
||||
/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#fff"
|
||||
android:textSize="20sp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="14.5sp"
|
||||
android:paddingEnd="14.5sp"
|
||||
android:minHeight="35sp"
|
||||
/>
|
||||
@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="always"
|
||||
android:icon="@drawable/ic_action_search"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
||||
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">App</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string-array name="items">
|
||||
<item>Item 1</item>
|
||||
<item>Item 2</item>
|
||||
<item>Item 3</item>
|
||||
<item>Item 4</item>
|
||||
<item>Item 5</item>
|
||||
<item>Item 6</item>
|
||||
</string-array>
|
||||
|
||||
<string name="drawer_open">Open navigation drawer</string>
|
||||
<string name="drawer_close">Close navigation drawer</string>
|
||||
</resources>
|
||||
@ -0,0 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@ -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<String>(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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue