SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Navigation Drawer
by Eakapong Kattiya
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer :Add ActionbarSherlock Library
Source : MyNavigationDrawer.zip
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer :Add ActionbarSherlock Library
Monday, July 15, 13
by Eakapong Kattiya
(1)Theme.Sherlock : styles.xml
<resources>
<style name="AppBaseTheme" parent="Theme.Sherlock.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
Change AppBaseTheme in styles.xml
Monday, July 15, 13
by Eakapong Kattiya
(2)Theme.Sherlock :AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
//..
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.mydrawerlayout.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer : activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
//..
<android.support.v4.widget.DrawerLayout
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"
android:background="#FF00FF" />
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer : main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
<item
android:id="@+id/action_websearch"
android:icon="@drawable/action_search"
android:showAsAction="ifRoom|withText"
android:title="Search"/>
</menu>
Monday, July 15, 13
import com.actionbarsherlock.app.SherlockFragmentActivity; //import android.app.Activity;
public class MainActivity extends SherlockFragmentActivity implements OnItemClickListener{
	 List<Integer> images = new ArrayList<Integer>();
	 List<String> items = new ArrayList<String>();
	 private ListView mDrawerList;
	 private DrawerLayout mDrawerLayout;
	 @Override
	 protected void onCreate(Bundle savedInstanceState) {
	 	 super.onCreate(savedInstanceState);
	 	 setContentView(R.layout.activity_main);
	 	 images.add(android.R.drawable.ic_menu_gallery);
	 	 images.add(android.R.drawable.ic_menu_camera);
	 	 items.add("Earth");
	 	 items.add("Jupiter");
	 	 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
	 	 mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // Set Shadow
	 	 mDrawerList = (ListView) findViewById(R.id.left_drawer);
	 	 ListAdapter adapter = new CustomArrayAdapter(this, items, images);
	 	 // Set the adapter for the list view
	 	 mDrawerList.setAdapter(adapter);
	 	 mDrawerList.setOnItemClickListener(this);
if (savedInstanceState == null) {
selectItem(0);
}
	 }
}
by Eakapong Kattiya
Navigation Drawer : MainActivity.java
Monday, July 15, 13
import com.actionbarsherlock.view.Menu; //import android.view.Menu;
public class MainActivity extends SherlockFragmentActivity
implements OnItemClickListener{
//..
@Override
	 public boolean onCreateOptionsMenu(Menu menu) {
	 	 //getMenuInflater().inflate(R.menu.main, menu);
	 	 getSupportMenuInflater().inflate(R.menu.main, menu);
	 	 return true;
	 }
}
by Eakapong Kattiya
Navigation Drawer : MainActivity.java
Monday, July 15, 13
import com.actionbarsherlock.view.Menu; //import android.view.Menu;
public class MainActivity extends SherlockFragmentActivity
implements OnItemClickListener{
//..
	 @Override
	 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
	 	 selectItem(arg2);
	 }
	 private void selectItem(int arg0) {
	 	 // update the main content by replacing fragments
	 	 PlanetFragment fragment = new PlanetFragment();
	 	 fragment.setPlanet(items.get(arg0));
	 	
	 	 FragmentManager fragmentManager = getSupportFragmentManager();
	 	 fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
	 	 // update selected item and title, then close the drawer
	 	 mDrawerList.setItemChecked(position, true);
	 	 mDrawerLayout.closeDrawer(mDrawerList);
	 }
}
by Eakapong Kattiya
Navigation Drawer : MainActivity.java
Monday, July 15, 13
import com.actionbarsherlock.view.Menu; //import android.view.Menu;
public class MainActivity extends SherlockFragmentActivity
implements OnItemClickListener{
//..
	 @Override
	 public boolean onOptionsItemSelected(final MenuItem item) {
	 	 // Handle action buttons
	 	 switch (item.getItemId()) {
	 	 case R.id.action_websearch:
	 	 	 // create intent to perform web search for this planet
	 	 	 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
	 	 	 intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle());
	 	 	 startActivity(intent);
	 	 	 return true;
	 	 default:
	 	 	 return super.onOptionsItemSelected(item);
	 	 }
	 }
}
by Eakapong Kattiya
Navigation Drawer : MainActivity.java
Monday, July 15, 13
public class CustomArrayAdapter extends ArrayAdapter<String> {
	 private List<Integer> images;
	 private List<String> items;
	 private Context context;
	 public CustomArrayAdapter(Context context, List<String> items, List<Integer> images) {
	 	 super(context, R.layout.drawer_list_item, items);
	 	 this.context = context;
	 	 this.images = images;
	 	 this.items = items ;
	 }
	 @Override
	 public View getView(int arg0, View convertView, ViewGroup parent) {
	 	 /* create a new view of my layout and inflate it in the row */
	 	 LayoutInflater inflator = (LayoutInflater) context
	 	 	 	 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	 	 View view = inflator.inflate(R.layout.drawer_list_item, null);
	 	
	 	 TextView textView = (TextView) view.findViewById(R.id.cityName);
	 	 textView.setText(items.get(arg0));
	 	
	 	 ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity);
	 	 String packageName = context.getPackageName();
	 	 String imageName = items.get(position).toLowerCase();
	 	 int resId = context.getResources().getIdentifier(imageName,"drawable", packageName);
	 	 imageCity.setImageResource(resId);
	 	 return view;
	 }
}
by Eakapong Kattiya
Navigation Drawer : CustomArrayAdapter.java
Monday, July 15, 13
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="80dip"
android:background="#222222" >
<ImageView
android:id="@+id/imageCity"
android:layout_width="50dp"
android:layout_height="50dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/imageCity"
android:orientation="vertical"
android:paddingLeft="10dp" >
<TextView
android:id="@+id/cityName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="18dp" />
<TextView
android:id="@+id/cityLink"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:textColor="#FFFFFF"
android:textSize="14dp" />
</LinearLayout>
</RelativeLayout>
by Eakapong Kattiya
Navigation Drawer : drawer_list_item.xml
Monday, July 15, 13
by Eakapong Kattiya
List vs ArrayList vs LinkedList
List is interface , not a concrete class.
List cannot be instantiated.
List<String> items = new List<String>() ;
ArrayList is an implementation of List.
List<String> items = new ArrayList<String>();
items.add("Earth");
items.add("Jupiter");
LinkedList is an implementation of List.
List<String> items = new LinkedList<String>();
items.add("Earth");
items.add("Jupiter");
Monday, July 15, 13
by Eakapong Kattiya
ArrayList vs LinkedList
- ส่วนใหญ่แล้วใช้ ArrayList
- ใช้ LinkedList เมื่อข้อมูลใหญ่มากเช่น เกิน 1 ล้านแถวจะทํางานเร็วกว่า
(Big-Oh น้อยกว่าเมื่อมีการเพิ่มข้อมูล)
http://leepoint.net/notes-java/algorithms/big-oh/bigoh.html
Algorithm
array
ArrayList
LinkedList
access front O(1) O(1)
access back O(1) O(1)
access middle O(1) O(N)
insert at front O(N) O(1)
insert at back O(1) O(1)
insert in middle O(N) O(1)
Monday, July 15, 13
by Eakapong Kattiya
Sort ArrayList
List<String> items = new ArrayList<String>();
items.add("Earth");
items.add("Jupiter");
Collections.sort(items); //Ascending Sort
Comparator<String> comparator = Collections.reverseOrder();
Collections.sort(items,comparator); //Descending Sort
Monday, July 15, 13
-Fragment is a chunk of user interface with its own life cycle.
-Fragment must exist within an Activity.
-Interaction with fragments is done through FragmentManager.
-Fragment API was introduced in API 11
-Use SherlockFragmentActivity , SherlockFragment
instead of native Fragment API
by Eakapong Kattiya
Fragment (>API 11)
Monday, July 15, 13
by Eakapong Kattiya
Fragment (>API 11)
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer : fragment_planet.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:gravity="center"
android:padding="32dp" />
</RelativeLayout>
Monday, July 15, 13
public class PlanetFragment extends SherlockFragment {
	 private String planet ;
	 public PlanetFragment() {
	
	 }
	 public String getPlanet() {
	 	 return planet;
	 }
	 public void setPlanet(String planet) {
	 	 this.planet = planet;
	 }
	 @Override
	 public View onCreateView(LayoutInflater inflater, ViewGroup container,
	 	 	 Bundle savedInstanceState) {
	 	 View view = inflater.inflate(R.layout.fragment_planet, container, false);
	 	 String packageName = getActivity().getPackageName();
	 	 String imageName = planet.toLowerCase();
	 	 int imageId = getResources().getIdentifier(imageName,"drawable", packageName);
	 	 ImageView imageView = (ImageView)view.findViewById(R.id.image);
	 	 imageView.setImageResource(imageId);
	 	 getActivity().setTitle(planet);
	 	 return view;
	 }
}
by Eakapong Kattiya
Navigation Drawer : PlanetFragment.java
Monday, July 15, 13
ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity);
Drawable image = context.getResources().getDrawable(android.R.drawable.ic_dialog_email);
imageCity.setImageDrawable(image);
by Eakapong Kattiya
ImageView
List<Integer> images = new ArrayList<Integer>();
images.add(android.R.drawable.ic_menu_gallery);
images.add(android.R.drawable.ic_menu_camera);
ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity);
Drawable image = context.getResources().getDrawable(images.get(0));
imageCity.setImageDrawable(image);
ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity);
String packageName = context.getPackageName();
String imageName = items.get(position).toLowerCase();
int resId = context.getResources().getIdentifier(imageName,"drawable", packageName);
imageCity.setImageResource(resId);
Fixed Resource id
Dynamic Resource id
Choose image name
Monday, July 15, 13
by Eakapong Kattiya
Nine-patch Image
Monday, July 15, 13
by Eakapong Kattiya
Nine-patch Image
Monday, July 15, 13
by Eakapong Kattiya
Nine-patch Image
res/drawable/drawer_shadow.9.png
Monday, July 15, 13
by Eakapong Kattiya
Navigation Drawer with ActionBarDrawerToggle
Source : MyNavigationDrawerToggle.zip
Monday, July 15, 13

Weitere ähnliche Inhalte

Was ist angesagt?

Material Design and Backwards Compatibility
Material Design and Backwards CompatibilityMaterial Design and Backwards Compatibility
Material Design and Backwards CompatibilityAngelo Rüggeberg
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in androidAngelo Rüggeberg
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesSamsung Developers
 
Android - Working with Fragments
Android - Working with FragmentsAndroid - Working with Fragments
Android - Working with FragmentsCan Elmas
 
Navigation Architecture Component
Navigation Architecture ComponentNavigation Architecture Component
Navigation Architecture ComponentYasutaka Kawamoto
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfMorgan Cheng
 
Simplified Android Development with Simple-Stack
Simplified Android Development with Simple-StackSimplified Android Development with Simple-Stack
Simplified Android Development with Simple-StackGabor Varadi
 
Google I/O 2021 Recap
Google I/O 2021 RecapGoogle I/O 2021 Recap
Google I/O 2021 Recapfurusin
 
Saindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidSaindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidDaniel Baccin
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
Handling action bar in Android
Handling action bar in AndroidHandling action bar in Android
Handling action bar in Androidindiangarg
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Mario Jorge Pereira
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleMathias Seguy
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 

Was ist angesagt? (20)

Material Design and Backwards Compatibility
Material Design and Backwards CompatibilityMaterial Design and Backwards Compatibility
Material Design and Backwards Compatibility
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
 
Introduction toandroid
Introduction toandroidIntroduction toandroid
Introduction toandroid
 
Eddystone beacons demo
Eddystone beacons demoEddystone beacons demo
Eddystone beacons demo
 
droidparts
droidpartsdroidparts
droidparts
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and Gestures
 
Android - Working with Fragments
Android - Working with FragmentsAndroid - Working with Fragments
Android - Working with Fragments
 
Navigation Architecture Component
Navigation Architecture ComponentNavigation Architecture Component
Navigation Architecture Component
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend Perf
 
Simplified Android Development with Simple-Stack
Simplified Android Development with Simple-StackSimplified Android Development with Simple-Stack
Simplified Android Development with Simple-Stack
 
Google I/O 2021 Recap
Google I/O 2021 RecapGoogle I/O 2021 Recap
Google I/O 2021 Recap
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Saindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender androidSaindo da zona de conforto… resolvi aprender android
Saindo da zona de conforto… resolvi aprender android
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Handling action bar in Android
Handling action bar in AndroidHandling action bar in Android
Handling action bar in Android
 
Mini curso Android
Mini curso AndroidMini curso Android
Mini curso Android
 
Minicurso Android
Minicurso AndroidMinicurso Android
Minicurso Android
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification Google
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 

Ähnlich wie Android basic 4 Navigation Drawer

Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
React Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかYukiya Nakagawa
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Robert DeLuca
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesMichael Galpin
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257newegg
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suitesToru Wonyoung Choi
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Alfredo Morresi
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrapdonnfelker
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил АнохинFwdays
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 

Ähnlich wie Android basic 4 Navigation Drawer (20)

Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
React Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのか
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suites
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Android crashcourse
Android crashcourseAndroid crashcourse
Android crashcourse
 
List adapter with multiple objects
List adapter with multiple objectsList adapter with multiple objects
List adapter with multiple objects
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrap
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 

Mehr von Eakapong Kattiya

(31 July 2013) iOS Basic Development Day 2 Human interface design
(31 July 2013) iOS Basic Development Day 2 Human interface design (31 July 2013) iOS Basic Development Day 2 Human interface design
(31 July 2013) iOS Basic Development Day 2 Human interface design Eakapong Kattiya
 
Evrdi : Social Diary ( iOS and Android )
Evrdi : Social Diary ( iOS and Android )Evrdi : Social Diary ( iOS and Android )
Evrdi : Social Diary ( iOS and Android )Eakapong Kattiya
 
Android Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADTAndroid Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADTEakapong Kattiya
 
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework Eakapong Kattiya
 
(1 July 2013) iOS Basic Development Day 5 - Submit to App Store
(1 July 2013) iOS Basic Development Day 5 - Submit to App Store(1 July 2013) iOS Basic Development Day 5 - Submit to App Store
(1 July 2013) iOS Basic Development Day 5 - Submit to App StoreEakapong Kattiya
 
Iphone developer advance twitter
Iphone developer advance   twitterIphone developer advance   twitter
Iphone developer advance twitterEakapong Kattiya
 
iOS Advance Development - Social Media
iOS Advance Development - Social MediaiOS Advance Development - Social Media
iOS Advance Development - Social MediaEakapong Kattiya
 
Iphone developer advance location based
Iphone developer advance location basedIphone developer advance location based
Iphone developer advance location basedEakapong Kattiya
 

Mehr von Eakapong Kattiya (8)

(31 July 2013) iOS Basic Development Day 2 Human interface design
(31 July 2013) iOS Basic Development Day 2 Human interface design (31 July 2013) iOS Basic Development Day 2 Human interface design
(31 July 2013) iOS Basic Development Day 2 Human interface design
 
Evrdi : Social Diary ( iOS and Android )
Evrdi : Social Diary ( iOS and Android )Evrdi : Social Diary ( iOS and Android )
Evrdi : Social Diary ( iOS and Android )
 
Android Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADTAndroid Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADT
 
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
 
(1 July 2013) iOS Basic Development Day 5 - Submit to App Store
(1 July 2013) iOS Basic Development Day 5 - Submit to App Store(1 July 2013) iOS Basic Development Day 5 - Submit to App Store
(1 July 2013) iOS Basic Development Day 5 - Submit to App Store
 
Iphone developer advance twitter
Iphone developer advance   twitterIphone developer advance   twitter
Iphone developer advance twitter
 
iOS Advance Development - Social Media
iOS Advance Development - Social MediaiOS Advance Development - Social Media
iOS Advance Development - Social Media
 
Iphone developer advance location based
Iphone developer advance location basedIphone developer advance location based
Iphone developer advance location based
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Kürzlich hochgeladen (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Android basic 4 Navigation Drawer

  • 1. Navigation Drawer by Eakapong Kattiya http://developer.android.com/training/implementing-navigation/nav-drawer.html Monday, July 15, 13
  • 2. by Eakapong Kattiya Navigation Drawer :Add ActionbarSherlock Library Source : MyNavigationDrawer.zip Monday, July 15, 13
  • 3. by Eakapong Kattiya Navigation Drawer :Add ActionbarSherlock Library Monday, July 15, 13
  • 4. by Eakapong Kattiya (1)Theme.Sherlock : styles.xml <resources> <style name="AppBaseTheme" parent="Theme.Sherlock.Light"> </style> <style name="AppTheme" parent="AppBaseTheme"> </style> </resources> Change AppBaseTheme in styles.xml Monday, July 15, 13
  • 5. by Eakapong Kattiya (2)Theme.Sherlock :AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" //.. <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.mydrawerlayout.MainActivity" android:label="@string/app_name" android:theme="@style/Theme.Sherlock" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> Monday, July 15, 13
  • 6. by Eakapong Kattiya Navigation Drawer : activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" //.. <android.support.v4.widget.DrawerLayout 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" android:background="#FF00FF" /> <!-- The navigation drawer --> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#FFFFFF" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" /> </android.support.v4.widget.DrawerLayout> </RelativeLayout> Monday, July 15, 13
  • 7. by Eakapong Kattiya Navigation Drawer : main.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_settings" android:orderInCategory="100" android:showAsAction="never" android:title="@string/action_settings"/> <item android:id="@+id/action_websearch" android:icon="@drawable/action_search" android:showAsAction="ifRoom|withText" android:title="Search"/> </menu> Monday, July 15, 13
  • 8. import com.actionbarsherlock.app.SherlockFragmentActivity; //import android.app.Activity; public class MainActivity extends SherlockFragmentActivity implements OnItemClickListener{ List<Integer> images = new ArrayList<Integer>(); List<String> items = new ArrayList<String>(); private ListView mDrawerList; private DrawerLayout mDrawerLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); images.add(android.R.drawable.ic_menu_gallery); images.add(android.R.drawable.ic_menu_camera); items.add("Earth"); items.add("Jupiter"); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // Set Shadow mDrawerList = (ListView) findViewById(R.id.left_drawer); ListAdapter adapter = new CustomArrayAdapter(this, items, images); // Set the adapter for the list view mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(this); if (savedInstanceState == null) { selectItem(0); } } } by Eakapong Kattiya Navigation Drawer : MainActivity.java Monday, July 15, 13
  • 9. import com.actionbarsherlock.view.Menu; //import android.view.Menu; public class MainActivity extends SherlockFragmentActivity implements OnItemClickListener{ //.. @Override public boolean onCreateOptionsMenu(Menu menu) { //getMenuInflater().inflate(R.menu.main, menu); getSupportMenuInflater().inflate(R.menu.main, menu); return true; } } by Eakapong Kattiya Navigation Drawer : MainActivity.java Monday, July 15, 13
  • 10. import com.actionbarsherlock.view.Menu; //import android.view.Menu; public class MainActivity extends SherlockFragmentActivity implements OnItemClickListener{ //.. @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { selectItem(arg2); } private void selectItem(int arg0) { // update the main content by replacing fragments PlanetFragment fragment = new PlanetFragment(); fragment.setPlanet(items.get(arg0)); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerLayout.closeDrawer(mDrawerList); } } by Eakapong Kattiya Navigation Drawer : MainActivity.java Monday, July 15, 13
  • 11. import com.actionbarsherlock.view.Menu; //import android.view.Menu; public class MainActivity extends SherlockFragmentActivity implements OnItemClickListener{ //.. @Override public boolean onOptionsItemSelected(final MenuItem item) { // Handle action buttons switch (item.getItemId()) { case R.id.action_websearch: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle()); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } } by Eakapong Kattiya Navigation Drawer : MainActivity.java Monday, July 15, 13
  • 12. public class CustomArrayAdapter extends ArrayAdapter<String> { private List<Integer> images; private List<String> items; private Context context; public CustomArrayAdapter(Context context, List<String> items, List<Integer> images) { super(context, R.layout.drawer_list_item, items); this.context = context; this.images = images; this.items = items ; } @Override public View getView(int arg0, View convertView, ViewGroup parent) { /* create a new view of my layout and inflate it in the row */ LayoutInflater inflator = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflator.inflate(R.layout.drawer_list_item, null); TextView textView = (TextView) view.findViewById(R.id.cityName); textView.setText(items.get(arg0)); ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity); String packageName = context.getPackageName(); String imageName = items.get(position).toLowerCase(); int resId = context.getResources().getIdentifier(imageName,"drawable", packageName); imageCity.setImageResource(resId); return view; } } by Eakapong Kattiya Navigation Drawer : CustomArrayAdapter.java Monday, July 15, 13
  • 13. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="80dip" android:background="#222222" > <ImageView android:id="@+id/imageCity" android:layout_width="50dp" android:layout_height="50dp" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_toRightOf="@id/imageCity" android:orientation="vertical" android:paddingLeft="10dp" > <TextView android:id="@+id/cityName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="18dp" /> <TextView android:id="@+id/cityLink" android:layout_width="fill_parent" android:layout_height="wrap_content" android:autoLink="web" android:textColor="#FFFFFF" android:textSize="14dp" /> </LinearLayout> </RelativeLayout> by Eakapong Kattiya Navigation Drawer : drawer_list_item.xml Monday, July 15, 13
  • 14. by Eakapong Kattiya List vs ArrayList vs LinkedList List is interface , not a concrete class. List cannot be instantiated. List<String> items = new List<String>() ; ArrayList is an implementation of List. List<String> items = new ArrayList<String>(); items.add("Earth"); items.add("Jupiter"); LinkedList is an implementation of List. List<String> items = new LinkedList<String>(); items.add("Earth"); items.add("Jupiter"); Monday, July 15, 13
  • 15. by Eakapong Kattiya ArrayList vs LinkedList - ส่วนใหญ่แล้วใช้ ArrayList - ใช้ LinkedList เมื่อข้อมูลใหญ่มากเช่น เกิน 1 ล้านแถวจะทํางานเร็วกว่า (Big-Oh น้อยกว่าเมื่อมีการเพิ่มข้อมูล) http://leepoint.net/notes-java/algorithms/big-oh/bigoh.html Algorithm array ArrayList LinkedList access front O(1) O(1) access back O(1) O(1) access middle O(1) O(N) insert at front O(N) O(1) insert at back O(1) O(1) insert in middle O(N) O(1) Monday, July 15, 13
  • 16. by Eakapong Kattiya Sort ArrayList List<String> items = new ArrayList<String>(); items.add("Earth"); items.add("Jupiter"); Collections.sort(items); //Ascending Sort Comparator<String> comparator = Collections.reverseOrder(); Collections.sort(items,comparator); //Descending Sort Monday, July 15, 13
  • 17. -Fragment is a chunk of user interface with its own life cycle. -Fragment must exist within an Activity. -Interaction with fragments is done through FragmentManager. -Fragment API was introduced in API 11 -Use SherlockFragmentActivity , SherlockFragment instead of native Fragment API by Eakapong Kattiya Fragment (>API 11) Monday, July 15, 13
  • 18. by Eakapong Kattiya Fragment (>API 11) Monday, July 15, 13
  • 19. by Eakapong Kattiya Navigation Drawer : fragment_planet.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:gravity="center" android:padding="32dp" /> </RelativeLayout> Monday, July 15, 13
  • 20. public class PlanetFragment extends SherlockFragment { private String planet ; public PlanetFragment() { } public String getPlanet() { return planet; } public void setPlanet(String planet) { this.planet = planet; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_planet, container, false); String packageName = getActivity().getPackageName(); String imageName = planet.toLowerCase(); int imageId = getResources().getIdentifier(imageName,"drawable", packageName); ImageView imageView = (ImageView)view.findViewById(R.id.image); imageView.setImageResource(imageId); getActivity().setTitle(planet); return view; } } by Eakapong Kattiya Navigation Drawer : PlanetFragment.java Monday, July 15, 13
  • 21. ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity); Drawable image = context.getResources().getDrawable(android.R.drawable.ic_dialog_email); imageCity.setImageDrawable(image); by Eakapong Kattiya ImageView List<Integer> images = new ArrayList<Integer>(); images.add(android.R.drawable.ic_menu_gallery); images.add(android.R.drawable.ic_menu_camera); ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity); Drawable image = context.getResources().getDrawable(images.get(0)); imageCity.setImageDrawable(image); ImageView imageCity = (ImageView) view.findViewById(R.id.imageCity); String packageName = context.getPackageName(); String imageName = items.get(position).toLowerCase(); int resId = context.getResources().getIdentifier(imageName,"drawable", packageName); imageCity.setImageResource(resId); Fixed Resource id Dynamic Resource id Choose image name Monday, July 15, 13
  • 22. by Eakapong Kattiya Nine-patch Image Monday, July 15, 13
  • 23. by Eakapong Kattiya Nine-patch Image Monday, July 15, 13
  • 24. by Eakapong Kattiya Nine-patch Image res/drawable/drawer_shadow.9.png Monday, July 15, 13
  • 25. by Eakapong Kattiya Navigation Drawer with ActionBarDrawerToggle Source : MyNavigationDrawerToggle.zip Monday, July 15, 13