我的 ActionBarSherlock 中有一个微调器,里面有 5 个元素。通过单击屏幕底部的两个按钮之一(见图),我想更改item id
.spinner
这是相关代码:
@Override
public void onCreate(Bundle savedInstanceState) {
/* ... some code ...*/
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.arr_contents, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setTitle(title);
/*... some other code ...*/
}
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
switch(itemPosition) {
case 0:
// Do stuff
break;
case 1:
// Do stuff
break;
case 2:
// Do stuff
break;
case 3:
// Do stuff
break;
case 4:
// Do stuff
break;
default:
// Do stuff
break;
}
return true;
}
例如,我尝试调用onNavigationItemSelected(3, R.array.arr_contents);
以移动到微调器的第三个元素,但它不起作用。我该怎么做?