Tôi đang cố gắng triển khai danh sách thả xuống làm điều hướng cho thanh tác vụ trong Android. Tôi có thể thấy danh sách thả xuống và các mục, nhưng tôi không thể nhận được sự kiện nhấp chuột.Android: Thanh tác vụ Sherlock thả xuống
Tôi không chắc chắn những gì tôi đang mất tích kể từ khi tôi được làm theo hướng dẫn trong http://developer.android.com/guide/topics/ui/actionbar.html
Đây là mã của tôi:
public void onCreate(Bundle savedInstanceState) {
OnNavigationListener mOnNavigationListener;
super.onCreate(savedInstanceState);
// setContentView(R.layout.info_layout);
// getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setNavigationMode(getSupportActionBar().NAVIGATION_MODE_LIST);
SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.navigation_array, android.R.layout.simple_dropdown_item_1line);
mOnNavigationListener = new OnNavigationListener() {
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
switch (itemPosition) {
case 1:
Intent i = new Intent();
i.setClass(getApplicationContext(), ZoekAndBoekActivity.class);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
// return super.onOptionsItemSelected(itemPosition);
return true;
}
};
getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
}
Cảm ơn rất nhiều trước!
không làm bất cứ điều gì, thậm chí không nhập vào onNavigationItemSelected – noloman
@ noloman Nếu giải pháp của bạn khác với những gì được đưa ra ở đây, nó sẽ hữu ích cho người khác nếu bạn đăng nó. –
Làm cách nào tôi có thể nhận được mục của vị trí đã chọn? –