美文网首页
ListView多选

ListView多选

作者: Swerve | 来源:发表于2017-04-10 10:23 被阅读0次
 //设置此模式之后能够在多选的时候屏蔽点击事件
        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;
            }

相关文章

网友评论

      本文标题:ListView多选

      本文链接:https://www.haomeiwen.com/subject/sawfattx.html