I am currently working ActionBar (ActionBarCompat) oriented project, I Need some Clarification about actionbar.
I am using spinner layout like this,
<
Try this code . In menu/main.xml :
-
in Activity :
private MenuItem mSpinnerItem1 = null;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater mi=getMenuInflater();
mi.inflate(R.menu.main, menu);
mSpinnerItem1 = menu.findItem( R.id.menu_spinner1);
View view1 = mSpinnerItem1.getActionView();
if (view1 instanceof Spinner)
{
final Spinner spinner = (Spinner) view1;
spinner.setAdapter(ad1);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected(AdapterView> arg0) {
// TODO Auto-generated method stub
}
});
}
return true;
}