//设置此模式之后能够在多选的时候屏蔽点击事件
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setAdapter(adapter);
listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
adapter.notifyDataSetChanged();
Log.i("--", "onItemCheckedStateChanged");
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
Log.i("--", "onCreateActionMode");
//设置多选之后的View
View view = LayoutInflater.from(AudioList.this).inflate(R.layout.delete, null);
mode.setCustomView(view);
//returnfalse不能进入多选模式
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
Log.i("--", "onPrepareActionMode");
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
Log.i("--", "onActionItemClicked");
return false;
}
网友评论