To have a different view in the action bar spinner than in the spinner list, you can use a BaseAdapter or an ArrayAdapter and override some methods:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Return a view which appears in the action bar.
return yourCustomView..;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
// Return a view which appears in the spinner list.
// Ignoring convertView to make things simpler, considering
// we have different types of views. If the list is long, think twice!
return super.getView(position, null, parent);
}
More specific details can be found from here: https://stackoverflow.com/a/15293471/1650683
==== EDIT ====
You can find how to integrate dropdown in ActionBar in This article, follow the instruction, you will get it done.
As to bring to a different layout after selecting an item on the spinner
, you should set fragment after user clicks on the dropdown item. Sample code:
mOnNavigationListener = new OnNavigationListener() {
// Get the same strings provided for the drop-down's ArrayAdapter
String[] strings = getResources().getStringArray(R.array.action_list);
@Override
public boolean onNavigationItemSelected(int position, long itemId) {
// Create new fragment from our own Fragment class
ListContentFragment newFragment = new ListContentFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
// Replace whatever is in the fragment container with this fragment
// and give the fragment a tag name equal to the string at the position
// selected
ft.replace(R.id.fragment_container, newFragment, strings[position]);
// Apply changes
ft.commit();
return true;
}
};