In android you could set a navigation list in action bar by passing spinner adapter and OnNavigationListener. the issue is that the navigation list dont fill most of the action bar, how to make it expand like the gmail app : Example of Gmail app :
My app:
And here's the code :
//... setting the array adapter
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
NavigationListener navigationListener = new NavigationListener();
ListAdapter listAdapter = new ListAdapter();
actionBar.setListNavigationCallbacks(listAdapter, navigationListener);
actionBar.setDisplayShowTitleEnabled(false);
Other problem i face is the size of the spinner item, they show up really small, is that because i dont pass customized textview (look at screenshot)? example of what i do :
private class ListAdapter extends BaseAdapter implements SpinnerAdapter {
public View getView(int pos, View view, ViewGroup viewGroup) {
TextView text = new TextView(context);
text.setText(arrayAdapter.getItem(pos).toString());
return text;
}
}
You want to implement the getDropDownView
method too. This lets you supply a different view for the dropdown list with the metrics and formatting you want.
Consider inflating the framework layouts android.R.layout.simple_spinner_item
and android.R.layout.simple_spinner_dropdown_item
for these situations. Use findViewById(android.R.id.text1)
to get the TextView
you should fill out in each one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With