Skip to content

Instantly share code, notes, and snippets.

@blundell
Last active December 31, 2015 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blundell/8025897 to your computer and use it in GitHub Desktop.
Save blundell/8025897 to your computer and use it in GitHub Desktop.
1 line annon inner class array initialisation because I want to be able to add & remove but I'm too lazy to extend BaseAdapter.
public class NavDrawerArrayAdapter extends ArrayAdapter<String> {
public NavDrawerArrayAdapter(final Context context) {
super(context, android.R.layout.simple_list_item_activated_1, android.R.id.text1,
new ArrayList<String>() {{
add(context.getString(R.string.nav_drawer_section_explore));
add(context.getString(R.string.nav_drawer_section_rewards));
add(context.getString(R.string.nav_drawer_section_offers));
add(context.getString(R.string.nav_drawer_section_events));
}});
refresh();
}
public void refresh() {
if (MyApplication.isSignedIn()) {
remove(getContext().getString(R.string.nav_drawer_section_sign_in_up));
add(getContext().getString(R.string.nav_drawer_section_account));
} else {
add(getContext().getString(R.string.nav_drawer_section_sign_in_up));
remove(getContext().getString(R.string.nav_drawer_section_account));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment