List of usage examples for android.widget ListView setItemChecked
public void setItemChecked(int position, boolean value)
From source file:monakhv.android.samlib.dialogs.SingleChoiceSelectDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.file_select, null); if (v == null) { Log.e(DEBUG_TAG, "Can not create View!!"); return null; }/*from ww w . ja v a2 s .c o m*/ ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_single_choice, data); ListView fileList = (ListView) v.findViewById(R.id.listFile); fileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); fileList.setAdapter(adapter); fileList.setOnItemClickListener(listener); if (selected != -1) { fileList.setItemChecked(selected, true); } getDialog().setTitle(title); Button close = (Button) v.findViewById(R.id.listFile_close); close.setOnClickListener(new OnClickListener() { public void onClick(View v) { Log.d(DEBUG_TAG, "Close clicked"); dismiss(); } }); return v; }
From source file:cz.muni.fi.japanesedictionary.fragments.ResultFragmentList.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { if (mDualPane) { l.setItemChecked(position, true); }//w w w . j av a2 s . c o m mCallbackTranslation.onTranslationSelected(position); }
From source file:com.battlelancer.seriesguide.ui.EpisodesFragment.java
/** * Highlight the given episode in the list. *//*from ww w .j a v a 2 s . co m*/ public void setItemChecked(int position) { ListView list = getListView(); list.setItemChecked(position, true); if (position <= list.getFirstVisiblePosition() || position >= list.getLastVisiblePosition()) { list.smoothScrollToPosition(position); } }
From source file:bbct.android.common.activity.BaseballCardList.java
private void setAllChecked(boolean checked) { ListView listView = this.getListView(); // Add 1 for the header view for (int i = 0; i < this.adapter.getCount() + 1; ++i) { listView.setItemChecked(i, checked); }/*from w w w . j av a2 s . co m*/ }
From source file:org.pixmob.droidlink.ui.EventsFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); l.setItemChecked(position, true); final String eventId = (String) v.getTag(EventCursorAdapter.TAG_ID); Log.i(TAG, "Opening event details for " + eventId); final Uri eventUri = Uri.withAppendedPath(EventsContract.CONTENT_URI, eventId); if (selectionListenerRef != null) { final OnEventSelectionListener selectionListener = selectionListenerRef.get(); if (selectionListener != null) { try { selectionListener.onEventSelected(eventUri); } catch (Exception e) { Log.e(TAG, "Event selection listener error", e); }/*from w ww .j a va 2 s.co m*/ } } }
From source file:com.ultramegasoft.flavordex2.dialog.AppImportDialog.java
@Override public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) { final Context context = getContext(); if (context == null) { return;//from w ww .j av a 2s.com } setListShown(true); final EntryListAdapter adapter = new EntryListAdapter(context); adapter.setMultiChoiceMode(true); adapter.swapCursor(data); setListAdapter(adapter); final ListView listView = getListView(); for (int i = 0; i < adapter.getCount(); i++) { listView.setItemChecked(i, true); } invalidateButtons(); }
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 {/*w w w . ja v a2s . c o 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.bydavy.card.receipts.activities.ReceiptListActivity.java
@Override public void onReceiptPageSelected(int index) { mListIndexSelected = index;//ww w .j a v a2s. c om // Link the pager fragment to the list fragment final ListView listView = mReceiptListFragment.getListView(); listView.setItemChecked(index, true); listView.smoothScrollToPosition(index); }
From source file:com.ratebeer.android.gui.fragments.AddAvailabilityFragment.java
private void clearSelection(ListView listView) { final int itemCount = listView.getCount(); for (int i = 0; i < itemCount; ++i) { listView.setItemChecked(i, false); }/* w w w . j a v a2s .c om*/ }
From source file:com.wheelly.fragments.LocationsListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, final long id) { BusProvider.getInstance().post(new LocationSelectedEvent(id, LocationsListFragment.this)); if (inSelectMode) { l.setItemChecked(position, true); final Intent intent = new Intent(); intent.putExtra(LocationActivity.LOCATION_ID_EXTRA, id); getActivity().setResult(Activity.RESULT_OK, intent); getActivity().finish();/*from w w w . j a va 2 s. c o m*/ } else { startActivityForResult(new Intent(getActivity(), LocationActivity.class) { { putExtra(LocationActivity.LOCATION_ID_EXTRA, id); } }, EDIT_LOCATION_REQUEST); } }