Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static final String[] mPlanetTitles = new String[] { "ABOUT", "SHARE THIS APP", "CONNECT WITH US", "LOGOUT"};
- mDrawerList.setAdapter(new CustomAdapter(this,mPlanetTitles));
- mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
- R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
- public void onDrawerClosed(View view) {
- super.onDrawerClosed(view);
- invalidateOptionsMenu();
- }
- public void onDrawerOpened(View drawerView) {
- super.onDrawerOpened(drawerView);
- invalidateOptionsMenu();
- }
- };
- mDrawerLayout.setDrawerListener(mDrawerToggle);
- public class CustomAdapter extends ArrayAdapter
- {
- private final Context context;
- private String[] optionList;
- public CustomAdapter(Context context,String[] data)
- {
- super(context, R.layout.drawer_list_item);
- this.context = context;
- optionList=data;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent)
- {
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View v = inflater.inflate(R.layout.drawer_list_item, parent, false);
- ImageView icon=(ImageView)v.findViewById(R.id.optionlogo);
- TextView optiontext=(TextView)v.findViewById(R.id.optiontext);
- TextView optionsubtext=(TextView)v.findViewById(R.id.optionsubtext);
- if(optionList[position].equals("ABOUT")) {
- Log.e("bhuvnesh", "ABOUT");
- optiontext.setText("ABOUT");
- icon.setImageResource(R.drawable.guggu_icon);
- optionsubtext.setText("The what and why of Guggu");
- }
- else if(optionList[position].equals("SHARE THIS APP")) {
- optiontext.setText("SHARE THIS APP");
- icon.setImageResource(R.drawable.share_icon);
- optionsubtext.setText("Tell your friends about Guggu");
- }
- else if(optionList[position].equals("CONNECT WITH US")) {
- optiontext.setText("CONNECT WITH US");
- icon.setImageResource(R.drawable.fb_icon);
- optionsubtext.setVisibility(View.GONE);
- }
- else if(optionList[position].equals("LOGOUT")) {
- optiontext.setText("LOGOUT");
- icon.setImageResource(R.drawable.logout_icon);
- optionsubtext.setVisibility(View.GONE);
- }
- return v;
- }
- }
- @Override
- public int getCount() {
- return optionList.length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement