1
longClick()에서 다중보기 선택을 사용 가능하게하려고합니다. 액션 모드 객체를 선언하고 startActionMode()를 호출해야합니까? 또한 단일 항목 클릭에 대한 메뉴 목록을 어떻게 변경합니까? 표시된대로 설명서를 참조로 사용했습니다.배치 상황 별 동작 모드
ListView listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setMultiChoiceModeListener(new MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
// Here you can do something when items are selected/de-selected,
// such as update the title in the CAB
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
// Respond to clicks on the actions in the CAB
switch (item.getItemId()) {
case R.id.menu_delete:
deleteSelectedItems();
mode.finish(); // Action picked, so close the CAB
return true;
default:
return false;
}
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Inflate the menu for the CAB
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.context, menu);
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
// Here you can make any necessary updates to the activity when
// the CAB is removed. By default, selected items are deselected/unchecked.
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
// Here you can perform updates to the CAB due to
// an invalidate() request
return false;
}
});
감사를 다음과 같이
이제 onPrepareActionMode을 수정할 수 있지만 이것은 내가) startActionMode (전화 어떻게? – Meenakshi
mActionMode = new UniversityList(). startActionMode (multichoice) 여기서 mActionMode는 ActionMode 객체이고 multichoice는 MultiChoiceModeListener 객체입니다. – Meenakshi