Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. static final String[] mPlanetTitles = new String[] { "ABOUT", "SHARE THIS APP", "CONNECT WITH US", "LOGOUT"};
  2. mDrawerList.setAdapter(new CustomAdapter(this,mPlanetTitles));
  3. mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  4. mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
  5. R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
  6.  
  7. public void onDrawerClosed(View view) {
  8. super.onDrawerClosed(view);
  9.  
  10. invalidateOptionsMenu();
  11. }
  12.  
  13. public void onDrawerOpened(View drawerView) {
  14. super.onDrawerOpened(drawerView);
  15.  
  16. invalidateOptionsMenu();
  17. }
  18. };
  19. mDrawerLayout.setDrawerListener(mDrawerToggle);
  20.  
  21. public class CustomAdapter extends ArrayAdapter
  22. {
  23. private final Context context;
  24. private String[] optionList;
  25. public CustomAdapter(Context context,String[] data)
  26. {
  27. super(context, R.layout.drawer_list_item);
  28. this.context = context;
  29. optionList=data;
  30. }
  31.  
  32. @Override
  33. public View getView(int position, View convertView, ViewGroup parent)
  34. {
  35. LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  36.  
  37. View v = inflater.inflate(R.layout.drawer_list_item, parent, false);
  38. ImageView icon=(ImageView)v.findViewById(R.id.optionlogo);
  39. TextView optiontext=(TextView)v.findViewById(R.id.optiontext);
  40. TextView optionsubtext=(TextView)v.findViewById(R.id.optionsubtext);
  41. if(optionList[position].equals("ABOUT")) {
  42. Log.e("bhuvnesh", "ABOUT");
  43. optiontext.setText("ABOUT");
  44. icon.setImageResource(R.drawable.guggu_icon);
  45. optionsubtext.setText("The what and why of Guggu");
  46. }
  47. else if(optionList[position].equals("SHARE THIS APP")) {
  48. optiontext.setText("SHARE THIS APP");
  49. icon.setImageResource(R.drawable.share_icon);
  50. optionsubtext.setText("Tell your friends about Guggu");
  51. }
  52. else if(optionList[position].equals("CONNECT WITH US")) {
  53. optiontext.setText("CONNECT WITH US");
  54. icon.setImageResource(R.drawable.fb_icon);
  55. optionsubtext.setVisibility(View.GONE);
  56. }
  57. else if(optionList[position].equals("LOGOUT")) {
  58. optiontext.setText("LOGOUT");
  59. icon.setImageResource(R.drawable.logout_icon);
  60. optionsubtext.setVisibility(View.GONE);
  61. }
  62.  
  63.  
  64. return v;
  65. }
  66. }
  67.  
  68. @Override
  69. public int getCount() {
  70. return optionList.length;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement