我发现了这个问题(Android 2.2 Spinner 在 Actionbar 中看起来很旧)并且我试过了,但它对我不起作用!我想在我的 Sherlock Actionbar 中创建一个 Spinner,但它在较低的 android 版本中看起来很旧。这是我的代码:
创建:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
}
Oncreateoptions 菜单:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater mi = getSupportMenuInflater();
mi.inflate(R.menu.list, menu);
final Spinner spinner = new Spinner(getSupportActionBar()
.getThemedContext());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getSupportActionBar().getThemedContext(),
R.layout.sherlock_spinner_item, new String[]{"Level 1", "Level 2", "Level 3"});
adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// clicked
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
menu.add("Level").setActionView(spinner)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}