List of usage examples for android.widget AbsListView CHOICE_MODE_MULTIPLE
int CHOICE_MODE_MULTIPLE
To view the source code for android.widget AbsListView CHOICE_MODE_MULTIPLE.
Click Source Link
From source file:com.audiokernel.euphonyrmt.fragments.OutputsFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ListAdapter arrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_multiple_choice, mOutputs); setListAdapter(arrayAdapter);/*from w w w.j a v a 2 s. c o m*/ getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); getListView().setOnItemClickListener(this); // Not needed since MainMenuActivity will take care of telling us to refresh if (!(getActivity() instanceof MainMenuActivity)) { refreshOutputs(); } }
From source file:ca.rmen.android.networkmonitor.app.prefs.SelectFieldsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Activity activity = getActivity();/*from w w w . j a va2 s .c o m*/ // Build the list of choices for the user. Look up the friendly label of each column name, and pre-select the one the user chose last time. final String[] columnLabels = NetMonColumns.getColumnLabels(activity); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(activity, android.R.layout.simple_list_item_multiple_choice, columnLabels); setListAdapter(adapter); ListView lv = getListView(); lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); // Preselect the columns from the preferences List<String> selectedColumns = NetMonPreferences.getInstance(activity).getSelectedColumns(); for (String selectedColumn : selectedColumns) { String selectedColumnLabel = NetMonColumns.getColumnLabel(activity, selectedColumn); int position = adapter.getPosition(selectedColumnLabel); lv.setItemChecked(position, true); } }
From source file:com.ultramegasoft.flavordex2.dialog.ImportDialog.java
@NonNull @Override//from w ww . j ava 2 s.co m @SuppressLint("InflateParams") public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getContext(); if (context == null) { return super.onCreateDialog(savedInstanceState); } final View root = LayoutInflater.from(context).inflate(R.layout.dialog_import, null); mListContainer = root.findViewById(R.id.list_container); mListView = root.findViewById(R.id.list); mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { invalidateButtons(); } }); final TextView emptyView = root.findViewById(R.id.empty); emptyView.setText(R.string.message_import_no_data); mListView.setEmptyView(emptyView); mProgressBar = root.findViewById(R.id.progress); mIncludeImages = root.findViewById(R.id.include_images); return new AlertDialog.Builder(context).setTitle(R.string.title_import).setIcon(R.drawable.ic_import) .setView(root).setPositiveButton(R.string.button_import, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { insertSelected(); } }).setNegativeButton(R.string.button_cancel, null).create(); }
From source file:com.sagar.sunshine.ItemChoiceManager.java
public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;//from w ww . j ava 2s . co 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.sharpcart.android.wizardpager.wizard.ui.MultipleChoiceFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_page, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); final ListView listView = (ListView) rootView.findViewById(android.R.id.list); setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); // Pre-select currently selected items. new Handler().post(new Runnable() { @Override/*www . ja va 2 s . c o m*/ public void run() { final ArrayList<String> selectedItems = mPage.getData().getStringArrayList(Page.SIMPLE_DATA_KEY); if (selectedItems == null || selectedItems.size() == 0) { return; } final Set<String> selectedSet = new HashSet<String>(selectedItems); for (int i = 0; i < mChoices.size(); i++) { if (selectedSet.contains(mChoices.get(i))) { listView.setItemChecked(i, true); } } } }); return rootView; }
From source file:ni.org.ics.zikapositivas.appmovil.wizard.ui.MultipleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_page, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); ((TextView) rootView.findViewById(R.id.label_hint)).setText(mPage.getHint()); final ListView listView = (ListView) rootView.findViewById(android.R.id.list); setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); // Pre-select currently selected items. new Handler().post(new Runnable() { @Override/*from w ww. ja v a2s . c o m*/ public void run() { ArrayList<String> selectedItems = mPage.getData().getStringArrayList(Page.SIMPLE_DATA_KEY); if (selectedItems == null || selectedItems.size() == 0) { return; } Set<String> selectedSet = new HashSet<String>(selectedItems); for (int i = 0; i < mChoices.size(); i++) { if (selectedSet.contains(mChoices.get(i))) { listView.setItemChecked(i, true); } } } }); return rootView; }
From source file:de.vanita5.twittnuker.popup.AccountSelectorPopupWindow.java
public AccountSelectorPopupWindow(Context context, View anchor) { mContext = context;/*from w ww .j a v a2 s . c om*/ mAnchor = anchor; final int themeAttr; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { themeAttr = android.R.attr.actionOverflowMenuStyle; } else { themeAttr = android.R.attr.popupMenuStyle; } mAdapter = new AccountsGridAdapter(context); final Resources resources = context.getResources(); final LayoutInflater inflater = LayoutInflater.from(context); final int themeColor = ThemeUtils.getUserAccentColor(context); if (!(context instanceof Factory)) { inflater.setFactory2(new ThemedViewFactory(themeColor)); } final View contentView = inflater.inflate(R.layout.popup_account_selector, null); mGridView = (GridView) contentView.findViewById(R.id.grid_view); mGridView.setAdapter(mAdapter); mGridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mAccountSelectionListener == null) return; mAccountSelectionListener.onSelectionChanged(getSelectedAccountIds()); } }); mPopup = new PopupWindow(context, null, themeAttr); mPopup.setFocusable(true); mPopup.setWidth(Utils.getActionBarHeight(context) * 2); mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT); mPopup.setContentView(contentView); }
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 ww . j a va 2 s . co 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."); } } }
From source file:ni.org.ics.estudios.appmovil.wizard.ui.MultipleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_page, container, false); mTitleTextInput = (TextView) rootView.findViewById(android.R.id.title); mTitleTextInput.setText(mPage.getTitle()); mTitleTextInput.setTextColor(Color.parseColor(mPage.getTextColor())); mHintTextInput = (TextView) rootView.findViewById(R.id.label_hint); mHintTextInput.setText(mPage.getHint()); mHintTextInput.setTextColor(Color.parseColor(mPage.getmHintTextColor())); final ListView listView = (ListView) rootView.findViewById(android.R.id.list); setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); // Pre-select currently selected items. new Handler().post(new Runnable() { @Override//from w w w . ja v a2s.c o m public void run() { ArrayList<String> selectedItems = mPage.getData().getStringArrayList(Page.SIMPLE_DATA_KEY); if (selectedItems == null || selectedItems.size() == 0) { return; } Set<String> selectedSet = new HashSet<String>(selectedItems); for (int i = 0; i < mChoices.size(); i++) { if (selectedSet.contains(mChoices.get(i))) { listView.setItemChecked(i, true); } } } }); return rootView; }
From source file:cn.wjh1119.bestnews.ui.fragment.ListItemChoiceManager.java
public void onClick(RecyclerView.ViewHolder vh) { if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) return;//from w w w. j a v a 2 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."); } } }