List of usage examples for android.widget ListView setChoiceMode
public void setChoiceMode(int choiceMode)
From source file:com.pindroid.fragment.SelectTagsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//from ww w. j ava2 s . c om mAdapter = new SimpleCursorAdapter(this.getActivity(), android.R.layout.simple_list_item_multiple_choice, null, new String[] { Tag.Name }, new int[] { android.R.id.text1 }, 0); setListAdapter(mAdapter); getLoaderManager().initLoader(0, null, this); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setFastScrollEnabled(true); lv.setItemsCanFocus(false); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); }
From source file:org.sociotech.fishification.ui.fragments.CreateFishFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Restore preferences SharedPreferences settings = getActivity().getSharedPreferences(MainActivity.PREFS_NAME, 0); String authorName = settings.getString("authorName", null); String fishName = settings.getString("fishName", null); int fishTypeIndex = settings.getInt("fishTypeIndex", -1); // Set Author name if (authorName != null && !authorName.isEmpty()) { setEditText(R.id.authorNameText, authorName); } else {//from ww w . ja v a 2s . co m getActivity().getSupportLoaderManager().initLoader(0, null, this); } // Set Fish Name if (fishName != null && !fishName.isEmpty()) { setEditText(R.id.fishNameText, fishName); } ListView lv = getListView(); lv.setCacheColorHint(Color.TRANSPARENT); // Improves scrolling performance lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Set Fish Type if (fishTypeIndex != -1) { lv.setItemChecked(fishTypeIndex, true); m_fishSelectedListener.onFishSelected(fishTypeIndex); } }
From source file:com.pindroid.fragment.BrowseTagsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.tag_view, null, new String[] { Tag.Name, Tag.Count }, new int[] { R.id.tag_name, R.id.tag_count }, 0); setListAdapter(mAdapter);// w w w. j a va 2 s . co m getLoaderManager().initLoader(0, null, this); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setFastScrollEnabled(true); lv.setOnItemClickListener(clickListener); lv.setItemsCanFocus(false); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); }
From source file:com.commonsware.cwac.masterdetail.MasterDetailStrategy.java
ListView buildListView(Activity host) { ListView result = new ListView(host); result.setId(android.R.id.list);/* w w w .j av a2s . co m*/ result.setChoiceMode(ListView.CHOICE_MODE_SINGLE); return (result); }
From source file:net.vivekiyer.GAL.CorporateAddressBookFragment.java
private void setSelectionMode(View view, Boolean isSelectable) { ListView lv = (ListView) view.findViewById(R.id.contactsListView); lv.setChoiceMode(isSelectable ? ListView.CHOICE_MODE_SINGLE : ListView.CHOICE_MODE_NONE); }
From source file:in.rab.bildkort.SentenceFragment.java
private void initList(ArrayList<String> sentences) { ArrayList<Spanned> spanneds = new ArrayList<>(); for (String sentence : sentences) { spanneds.add(Html.fromHtml(sentence)); }/* ww w . ja va 2s . co m*/ ArrayAdapter<Spanned> adapter = new ArrayAdapter<>(getActivity(), R.layout.simple_list_item_multiple_choice_left, spanneds); mSentences = sentences; ListView listView = getListView(); setListAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); }
From source file:com.deliciousdroid.fragment.BrowseBundlesFragment.java
@Override public void onActivityCreated(android.os.Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/* ww w . j ava 2 s.c o m*/ mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.bundle_view, null, new String[] { Bundle.Name, Bundle.Tags }, new int[] { R.id.bundle_name, R.id.bundle_tags }, 0); setListAdapter(mAdapter); getLoaderManager().initLoader(0, null, this); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setFastScrollEnabled(true); lv.setOnItemClickListener(clickListener); lv.setItemsCanFocus(false); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); }
From source file:com.deliciousdroid.fragment.BrowseTagsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/*from w ww . java 2s . c o m*/ mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.tag_view, null, new String[] { Tag.Name, Tag.Count }, new int[] { R.id.tag_name, R.id.tag_count }, 0); setListAdapter(mAdapter); getLoaderManager().initLoader(0, null, this); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setFastScrollEnabled(true); lv.setOnItemClickListener(clickListener); lv.setItemsCanFocus(false); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); }
From source file:br.com.hojeti.wizardpager.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 w w. j a va2 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:net.i2p.android.wizard.ui.SingleChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_wizard_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() { 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; }//ww w . ja v a 2s . c om } } }); return rootView; }