1
내 작업 표시 줄 sherlock에 목록이 있습니다. 나는 사용자가 그 목록을 클릭 할 때 얻고 싶다. 사용자가 항목을 클릭 할 때를 알고 싶지 않습니다. 이미 알고 있습니다 (onNavigationItemSelected). 내에서 onCreate()에서ListNavigation 작업 표시 줄에서 클릭하십시오.
:
내 작업 표시 줄의 목록 탐색에 프로그래밍 방식으로 할 때 사용자가 클릭을 감지 할// Set action bar
final ActionBar actionBar = getSherlockActivity().getSupportActionBar();
if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_LIST) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
}
actionBar.setDisplayShowTitleEnabled(false);
mSelectionAdapter = new SelectionAdapter(getSherlockActivity().getSupportActionBar().getThemedContext(), R.layout.sherlock_spinner_dropdown_item, kinds);
actionBar.setListNavigationCallbacks(mSelectionAdapter, this);
.
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
int itemId = item.getItemId();
//using logcat you may see what the list item id is?
Log.i(TAG, "clicked actionbar itemid is: " + itemId);
//here you can setup a listener for every actionbar item selected
switch (itemId) {
//android.R.id.list might not be the one you are searching pls check it out and compare it to logcat and put the appropriate itemId here
case android.R.id.list:
//do whatever you want to do when list item is clicked
break;
}
return true;
}
내가하지 :( –
내 대답을 업데이트 작업 tryiedit : 목록 메뉴 클릭으로 다음과 같이 액션 바 항목은, 다음
onMenuItemSelected
를 재정의해야 할 때 –