Triggering multiple listviews for a single contextual menu. Not sure if it is even possible

48 views Asked by At

I currently have multiple lisview's that have contextual menu's that allows users t delete items. I havent been able to find any topics on this. Is it possible to have all of the listviews triggered at the same time to delete them without having to click on each list to get their own contextual menu?

Currently I am only able to click on one listview after the contextualmenu is brought to front. I beleive it has to to with :

 listBreakfast.setMultiChoiceModeListener(this);
 listLunch.setMultiChoiceModeListener(this);

They are being implemented separately. Below is the implementations within the activity.

listBreakfast.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listBreakfast.setMultiChoiceModeListener(this);
listLunch.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listLunch.setMultiChoiceModeListener(this);

public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_item_delete :

            for (int i = listBreakfast.getCount() - 1; i >= 0; i--) {
                if (listBreakfast.isItemChecked(i)) {
                    lb = logsAdapter1.getItem(i);
                    lb.delete1();
                    logsAdapter1.remove(logsAdapter1.getItem(i));
                    logsAdapter1.notifyDataSetChanged();

                }

            } 


            for (int i = listLunch.getCount() - 1; i >= 0; i--) {
                if (listLunch.isItemChecked(i)) {
                    ll = logsAdapter11.getItem(i);
                    ll.delete();
                    logsAdapter11.remove(logsAdapter11.getItem(i));
                    logsAdapter11.notifyDataSetChanged();

                }

            }
            mode.finish();
            logsAdapter.notifyDataSetChanged();
            logsAdapter11.notifyDataSetChanged();
            return true;
        default :
            return false;
    }
}
0

There are 0 answers