List of usage examples for android.widget ListView setChoiceMode
public void setChoiceMode(int choiceMode)
From source file:com.grottworkshop.gwswizardpager.ui.SingleChoiceFragment.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()); final ListView listView = (ListView) rootView.findViewById(android.R.id.list); setListAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override/*from ww w.j av a2 s.com*/ public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }
From source file:wizard.ui.SingleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.add_balance_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_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override//w ww . j av a 2 s . c o m public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }
From source file:com.jaspersoft.android.jaspermobile.dialog.CalendarDayDialogFragment.java
@NonNull @Override/*w w w. j av a 2 s. c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); ListView listView = (ListView) inflater.inflate(mListLayout, null); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); final List<CheckItem> items = createItems(); final Adapter adapter = new Adapter(getActivity(), listView, mMultiChoiceItemLayout, items); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int which, long id) { ListView listView = (ListView) parent; boolean isChecked = listView.isItemChecked(which); if (which == 0) { for (CheckItem item : items) { item.checked = isChecked; } selectedDays.clear(); if (isChecked) { selectedDays.addAll(days); } } else { int index = which - 1; CalendarViewRecurrence.Day item = days.get(index); if (isChecked) { selectedDays.add(item); } else { selectedDays.remove(item); } items.get(which).checked = isChecked; boolean allSelected = selectedDays.containsAll(days); items.get(0).checked = allSelected; } adapter.notifyDataSetChanged(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sr_days); builder.setView(listView); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mDialogListener != null) { ((DaysSelectedListener) mDialogListener).onDaysSelected(selectedDays); } } }); builder.setNegativeButton(R.string.cancel, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.jaspersoft.android.jaspermobile.dialog.CalendarMonthDialogFragment.java
@NonNull @Override/*ww w. j a v a2 s . co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); ListView listView = (ListView) inflater.inflate(mListLayout, null); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); final List<CheckItem> items = createItems(); final Adapter adapter = new Adapter(getActivity(), listView, mMultiChoiceItemLayout, items); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int which, long id) { ListView listView = (ListView) parent; boolean isChecked = listView.isItemChecked(which); if (which == 0) { for (CheckItem item : items) { item.checked = isChecked; } selectedMonths.clear(); if (isChecked) { selectedMonths.addAll(months); } } else { int index = which - 1; CalendarViewRecurrence.Month item = months.get(index); if (isChecked) { selectedMonths.add(item); } else { selectedMonths.remove(item); } items.get(which).checked = isChecked; boolean allSelected = selectedMonths.containsAll(months); items.get(0).checked = allSelected; } adapter.notifyDataSetChanged(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sr_months); builder.setView(listView); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mDialogListener != null) { ((MonthsSelectedListener) mDialogListener).onMonthsSelected(selectedMonths); } } }); builder.setNegativeButton(R.string.cancel, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.sharpcart.android.wizardpager.wizard.ui.SingleChoiceFragment.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_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override//from w w w .j a v a2s.c o m public void run() { final String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }
From source file:ni.org.ics.zikapositivas.appmovil.wizard.ui.SingleChoiceFragment.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_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override/*from w w w .j a v a 2s .c o m*/ public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }
From source file:pl.arnea.footballadventuremanager.wizardpager.wizard.ui.SingleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.wizardpager_single_page_fragment, 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_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override//from www .ja v a 2s. com public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); GlobalData.MYCLUBID = i; break; } } } }); return rootView; }
From source file:br.com.PartoHumanizado.fragment.base.ResStringArrayListFragment.java
private void updateListView() { ListView listView = getListView(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(listView.getContext(), R.layout.item_plano_de_parto, android.R.id.text1, stringArray); listView.setAdapter(adapter);//from w ww .j av a 2 s .c om listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setItemsCanFocus(false); }
From source file:com.example.flashcards.wizardpager.wizard.ui.SingleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(LOG_TAG, "getSctivity() " + getActivity()); 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_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override//w w w .j a va 2 s.c o m public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }
From source file:com.lastsoft.plog.wizard.ui.SingleChoiceFragment.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()); final ListView listView = (ListView) rootView.findViewById(android.R.id.list); setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_single_choice, android.R.id.text1, mChoices)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Pre-select currently selected item. new Handler().post(new Runnable() { @Override/*from w ww . j a va2s . c o m*/ public void run() { String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY); for (int i = 0; i < mChoices.size(); i++) { if (mChoices.get(i).equals(selection)) { listView.setItemChecked(i, true); break; } } } }); return rootView; }