List of usage examples for android.widget AbsListView CHOICE_MODE_MULTIPLE_MODAL
int CHOICE_MODE_MULTIPLE_MODAL
To view the source code for android.widget AbsListView CHOICE_MODE_MULTIPLE_MODAL.
Click Source Link
From source file:it.gulch.linuxday.android.widgets.BookmarksMultiChoiceModeListener.java
public static void register(AbsListView listView, BookmarkManager bookmarkManager) { listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); BookmarksMultiChoiceModeListener listener = new BookmarksMultiChoiceModeListener(listView, bookmarkManager); listView.setMultiChoiceModeListener(listener); }
From source file:st.alr.homA.ActivityQuickpublishNfc.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quickpublish); listView = (ListView) findViewById(R.id.records); adapter = new QuickpublishAdapter(this); listView.setAdapter(adapter);/* ww w . j a va2 s .co m*/ listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(multiChoiceListener); writeMode = false; }
From source file:org.jraf.android.bikey.app.ride.list.RideListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setEmptyText(getString(R.string.ride_list_empty)); ListView listView = getListView(); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override//from www . j av a 2s. co m public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.setTitle(R.string.ride_list_title); int quantity = getListView().getCheckedItemCount(); mode.setSubtitle( getResources().getQuantityString(R.plurals.ride_list_cab_subtitle, quantity, quantity)); MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.ride_list_contextual, menu); return true; } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { int quantity = getListView().getCheckedItemCount(); mode.setSubtitle( getResources().getQuantityString(R.plurals.ride_list_cab_subtitle, quantity, quantity)); // Enable share / edit if only one item is selected (can't share / edit several items at the same time) mode.getMenu().findItem(R.id.action_share).setVisible(quantity == 1); mode.getMenu().findItem(R.id.action_edit).setVisible(quantity == 1); // Enable merge only if several items are selected mode.getMenu().findItem(R.id.action_merge).setVisible(quantity > 1); } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { long[] checkedItemIds = getListView().getCheckedItemIds(); long checkedItemId = checkedItemIds[0]; Uri checkedItemUri = ContentUris.withAppendedId(RideColumns.CONTENT_URI, checkedItemId); switch (item.getItemId()) { case R.id.action_delete: getCallbacks().showDeleteDialog(checkedItemIds); mode.finish(); return true; case R.id.action_share: getCallbacks().showShareDialog(checkedItemUri); mode.finish(); return true; case R.id.action_edit: getCallbacks().edit(checkedItemUri); mode.finish(); return true; case R.id.action_merge: getCallbacks().showMergeDialog(checkedItemIds); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); }
From source file:com.sagar.sunshine.ItemChoiceManager.java
public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;/* w ww.j a v a2 s. c o m*/ int checkedItemCount = mCheckStates.size(); int position = vh.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) { Log.d(LOG_TAG, "Unable to Set Item State"); return; } switch (mChoiceMode) { case AbsListView.CHOICE_MODE_NONE: break; case AbsListView.CHOICE_MODE_SINGLE: { boolean checked = mCheckStates.get(position, false); if (!checked) { for (int i = 0; i < checkedItemCount; i++) { mAdapter.notifyItemChanged(mCheckStates.keyAt(i)); } mCheckStates.clear(); mCheckStates.put(position, true); mCheckedIdStates.clear(); mCheckedIdStates.put(mAdapter.getItemId(position), position); } mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE: { boolean checked = mCheckStates.get(position, false); mCheckStates.put(position, !checked); mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: { throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager."); } } }
From source file:com.nearnotes.NoteList.java
@Override public void onStart() { super.onStart(); mCallback.setActionItems(NOTE_LIST); mSelectedIds = new ArrayList<Long>(); mDbHelper = new NotesDbAdapter(getActivity()); // Create new custom database class for sqlite and pass the current context as a variable mDbHelper.open(); // Gets the writable database Bundle bundle = getArguments();/*www. j a va 2s . c o m*/ mLongitude = bundle.getDouble("longitude"); mLatitude = bundle.getDouble("latitude"); fillData(mLongitude, mLatitude); mListView = getListView(); getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().setMultiChoiceModeListener(new MultiChoiceModeListener() { private int nr = 0; @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { mActionModeFlag = false; Log.e("onDestroyActionMode", "onDestroyActionMode"); mAdapter.clearSelection(); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mActionModeFlag = true; nr = 0; MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.contextual_menu, menu); return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.context_delete: for (Long s : mSelectedIds) { mDbHelper.deleteNote(s); if (mDbHelper.fetchSetting() == s) { mDbHelper.removeSetting(); } } nr = 0; mAdapter.clearSelection(); fillData(mLongitude, mLatitude); mode.finish(); return true; case R.id.context_select_all: SparseBooleanArray checkSparse = getListView().getCheckedItemPositions(); for (int i = 0; i < mListView.getCount(); i++) { if (!checkSparse.get(i)) { getListView().setItemChecked(i, true); } } return true; } return false; } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { Log.e("checked", String.valueOf(checked) + " id: " + String.valueOf(id) + " position: " + String.valueOf(position)); if (checked) { nr++; mSelectedIds.add(id); mAdapter.setNewSelection(position, checked); } else { mSelectedIds.remove(id); nr--; mAdapter.removeSelection(position); } TextView tv = (TextView) getActivity().getLayoutInflater().inflate(R.layout.contextual_title, null); tv.setText(nr + " selected"); mode.setCustomView(tv); } }); getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long arg3) { getListView().setItemChecked(position, !mAdapter.isPositionChecked(position)); return false; } }); }
From source file:ru.arturvasilov.udacity.sunshinewatches.ItemChoiceManager.java
@SuppressWarnings("unchecked") public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;/*from w w w.j av a 2 s .c om*/ int checkedItemCount = mCheckStates.size(); int position = vh.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) { Log.d(LOG_TAG, "Unable to Set Item State"); return; } switch (mChoiceMode) { case AbsListView.CHOICE_MODE_NONE: break; case AbsListView.CHOICE_MODE_SINGLE: { boolean checked = mCheckStates.get(position, false); if (!checked) { for (int i = 0; i < checkedItemCount; i++) { mAdapter.notifyItemChanged(mCheckStates.keyAt(i)); } mCheckStates.clear(); mCheckStates.put(position, true); mCheckedIdStates.clear(); mCheckedIdStates.put(mAdapter.getItemId(position), position); } // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE: { boolean checked = mCheckStates.get(position, false); mCheckStates.put(position, !checked); // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: { throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager."); } } }
From source file:org.kei.android.phone.mangastore.AppFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(layout_id, container, false); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout); listMangas = (ListView) rootView.findViewById(R.id.list); listMangas.setAdapter(adapter);/*from w ww .j ava2 s . c o m*/ indexer.initialize(rootView); multiChoice = new ListMultiChoice(((MangaStorePagerActivity) getActivity()), listMangas); gestureDetector = new GestureDetector(rootView.getContext(), indexer); listMangas.setOnItemClickListener(this); listMangas.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listMangas.setMultiChoiceModeListener(multiChoice); rootView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View v, final MotionEvent event) { if (gestureDetector.onTouchEvent(event)) return true; else return false; } }); swipeRefreshLayout.setOnRefreshListener(this); /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); fetch(); } }); return rootView; }
From source file:com.fusionx.lightirc.ui.UserListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mStickyListView = (StickyListHeadersListView) view.findViewById(android.R.id.list); mAdapter = new UserListAdapter(view.getContext(), mWorldUsers); getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().getWrappedList().setMultiChoiceModeListener(this); getListView().setOnItemClickListener(this); getListView().setFastScrollEnabled(true); }
From source file:cn.wjh1119.bestnews.ui.fragment.ListItemChoiceManager.java
public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;/* w ww . jav a2 s. c o m*/ int checkedItemCount = mCheckStates.size(); int position = vh.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) { Logger.d(LOG_TAG, "Unable to Set Item State"); return; } switch (mChoiceMode) { case AbsListView.CHOICE_MODE_NONE: break; case AbsListView.CHOICE_MODE_SINGLE: { boolean checked = mCheckStates.get(position, false); if (!checked) { for (int i = 0; i < checkedItemCount; i++) { mAdapter.notifyItemChanged(mCheckStates.keyAt(i)); } mCheckStates.clear(); mCheckStates.put(position, true); mCheckedIdStates.clear(); mCheckedIdStates.put(mAdapter.getItemId(position), position); } // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE: { boolean checked = mCheckStates.get(position, false); mCheckStates.put(position, !checked); // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: { throw new RuntimeException("Multiple Modal not implemented in ListItemChoiceManager."); } } }
From source file:app.com.example.android.sunshine.ItemChoiceManager.java
public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;//www . j av a 2 s . c o m int checkedItemCount = mCheckStates.size(); int position = vh.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) { Log.d(LOG_TAG, "Unable to Set Item State"); return; } switch (mChoiceMode) { case AbsListView.CHOICE_MODE_NONE: break; case AbsListView.CHOICE_MODE_SINGLE: { boolean checked = mCheckStates.get(position, false); if (!checked) { for (int i = 0; i < checkedItemCount; i++) { mAdapter.notifyItemChanged(mCheckStates.keyAt(i)); } mCheckStates.clear(); mCheckStates.put(position, true); mCheckedIdStates.clear(); mCheckedIdStates.put(mAdapter.getItemId(position), position); } // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE: { boolean checked = mCheckStates.get(position, false); mCheckStates.put(position, !checked); // We directly call onBindViewHolder here because notifying that an item has // changed on an item that has the focus causes it to lose focus, which makes // keyboard navigation a bit annoying mAdapter.onBindViewHolder(vh, position); break; } case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: { throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager."); } } }