I am working on a app with action bar for navigation. Now I am trying to add a Spinner
to the ActionBar
.
I am able to get my custom icon on the ActionBar
. But when I add entries into the spinner, the icon is hidden behind the selection box with first item selected.
I want to have only the icon in the ActionBar
and the drop-down-list/spinner
to appear when tapped on the icon.
This is my code :
private void initializeMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options, menu);
View v = (View) menu.findItem(R.id.menuSort).getActionView();
Spinner spinner=(Spinner)v.findViewById(R.id.bookmarks_menu);
Bookmark bookmark1 = new Bookmark();
Bookmark bookmark2 = new Bookmark();
List<Bookmark> list = new ArrayList<Bookmark>();
list.add(bookmark1);
list.add(bookmark2);
SpinAdapter adapter = new SpinAdapter(getApplicationContext(),0, list);
spinner.setAdapter(adapter);
}