如何在多次单击时使ImageView不可见(ListView)

时间:2018-11-08 04:10:09

标签: java android listview imageview

ImageView中多次单击时,我想隐藏Listview

我确实这样:

listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            final int checkedCount = listView.getCheckedItemCount();
            mode.setTitle(checkedCount + " Selected");
            if(checked) {
                imageView.setVisibility(View.INVISIBLE);
            } else {
                imageView.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
                    return false;

                default:
                    return false;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater menuInflater = mode.getMenuInflater();
            menuInflater.inflate(R.menu.toolbar_mode, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }
    });

但是只有一项是不可见的,我得到了错误。

如果有的话,我有针对ListView的自定义适配器。谢谢。

0 个答案:

没有答案