List of usage examples for android.widget ListView setItemChecked
public void setItemChecked(int position, boolean value)
From source file:com.csipsimple.ui.calllog.CallLogListFragment.java
private void actionModeInvertSelection() { ListView lv = getListView(); for (int i = 0; i < lv.getCount(); i++) { lv.setItemChecked(i, !lv.isItemChecked(i)); }//from w w w . j av a2s .c o m mMode.invalidate(); }
From source file:com.csipsimple.ui.calllog.CallLogListFragment.java
@Override public void viewDetails(int position, long[] callIds) { ListView lv = getListView(); if (mMode != null) { lv.setItemChecked(position, !lv.isItemChecked(position)); mMode.invalidate();//from w w w . j av a 2s . c o m // Don't see details in this case return; } if (mDualPane) { // If we are not currently showing a fragment for the new // position, we need to create and install a new one. CallLogDetailsFragment df = new CallLogDetailsFragment(); Bundle bundle = new Bundle(); bundle.putLongArray(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds); df.setArguments(bundle); // Execute a transaction, replacing any existing fragment // with this one inside the frame. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, df, null); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); getListView().setItemChecked(position, true); } else { Intent it = new Intent(getActivity(), CallLogDetailsActivity.class); it.putExtra(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds); getActivity().startActivity(it); } }
From source file:com.ushahidi.android.app.ui.tablet.ListCheckinFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { l.setItemChecked(position, true); if (fetchedAdapter == adapter.getAdapter(position - 1)) { int itemAt = (adapter.getCount() - position); launchViewCheckin((fetchedAdapter.getCount() - itemAt) - 1); } else if (pendingAdapter == adapter.getAdapter(position - 1)) { int itemPosition = pendingAdapter.getCount() - position; int itemAt = (pendingAdapter.getCount() - itemPosition) - 1; launchAddCheckin((int) pendingAdapter.getItem(itemAt - 1).getDbId()); }/*from w w w . j a v a 2 s. c o m*/ }
From source file:org.gnucash.android.ui.export.ScheduledExportListFragment.java
/** * Unchecks all the checked items in the list */// w ww .ja va 2s .co m private void uncheckAllItems() { SparseBooleanArray checkedPositions = getListView().getCheckedItemPositions(); ListView listView = getListView(); for (int i = 0; i < checkedPositions.size(); i++) { int position = checkedPositions.keyAt(i); listView.setItemChecked(position, false); } }
From source file:com.jefftharris.passwdsafe.PasswdSafeListFragment.java
@Override public void onLoadFinished(Loader<List<PasswdRecordListData>> loader, List<PasswdRecordListData> data) { int selPos = itsAdapter.setData(data, itsIsContents ? itsSelectedRecord : itsLocation.getRecord()); if (isResumed()) { ListView list = getListView(); if (selPos != -1) { list.setItemChecked(selPos, true); list.smoothScrollToPosition(selPos); } else {/*from w w w. j av a 2 s . c om*/ list.clearChoices(); } if (itsEmptyText.getText().length() == 0) { itsEmptyText.setText(itsIsContents ? R.string.no_records : R.string.no_groups); } } }
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 va 2s. 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:org.gnucash.android.ui.transactions.TransactionsListFragment.java
/** * Selects a transaction in the list of transaction * @param position Position of the item which was selected *//* ww w .j av a 2s . c o m*/ private void selectItem(int position) { ListView lv = getListView(); lv.setItemChecked(position, true); View v = lv.getChildAt(position - lv.getFirstVisiblePosition()); v.setSelected(true); v.setBackgroundColor(getResources().getColor(R.color.abs__holo_blue_light)); long id = lv.getItemIdAtPosition(position); mSelectedIds.put(position, id); }
From source file:com.roamprocess1.roaming4world.ui.account.AccountsEditListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Log.d(THIS_FILE, "Checked " + position + " et " + id); ListView lv = getListView(); lv.setItemChecked(position, true); curCheckPosition = id;//from www . j a va 2 s.c om Cursor c = (Cursor) getListAdapter().getItem(position - lv.getHeaderViewsCount()); //showDetails(id, c.getString(c.getColumnIndex(SipProfile.FIELD_WIZARD))); }
From source file:org.gnucash.android.ui.transactions.TransactionsListFragment.java
/** * Deselects an item at <code>position</code> * @param position//from w w w . j ava 2s. co m */ private void deselectItem(int position) { if (position >= 0) { ListView listView = getListView(); listView.setItemChecked(position, false); View v = getListView().getChildAt(position - listView.getFirstVisiblePosition()); if (v == null) { //if we just deleted a row, then the previous position is invalid return; } v.setBackgroundColor(getResources().getColor(android.R.color.transparent)); ((CheckBox) v.findViewById(R.id.checkbox)).setChecked(false); v.setSelected(false); mSelectedIds.remove(position); } }
From source file:org.gnucash.android.ui.accounts.AccountsListFragment.java
/** * Highlights the item at <code>position</code> in the ListView. * Android has facilities for managing list selection but the highlighting * is not reliable when using the ActionBar on pre-Honeycomb devices- * @param position Position of item to be highlighted *///w w w . j av a 2 s . c o m private void selectItem(int position) { deselectPreviousSelectedItem(); ListView lv = getListView(); lv.setItemChecked(position, true); View v = lv.getChildAt(position - lv.getFirstVisiblePosition()); v.setSelected(true); v.setBackgroundColor(getResources().getColor(R.color.abs__holo_blue_light)); mSelectedViewPosition = position; }