0
我有導航菜單項。目前我在onCreateOptionsMenu中手動創建它:如何使用xml創建導航菜單項
public boolean onCreateOptionsMenu(Menu menu) {
mLocations = getResources().getStringArray(R.array.locations);
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(
context, R.array.locations, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
}
有沒有一種方法可以在XML中定義它?