List of usage examples for android.widget ListView setItemChecked
public void setItemChecked(int position, boolean value)
From source file:com.akalipetis.action_mode_list_fragment.ActionModeListFragment.java
@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ListView list = getListView(); int choiceMode = list.getChoiceMode(); mLastChoiceMode = choiceMode;//from w ww . java 2 s .c o m if (choiceMode == ListView.CHOICE_MODE_SINGLE) mLastCheckedItem = list.getCheckedItemPosition(); else mLastCheckedItem = ListView.INVALID_POSITION; if (Build.VERSION.SDK_INT < 11) { list.setItemChecked(mLastCheckedItem, false); list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); list.setLongClickable(false); ((ActionBarActivity) getActivity()).startSupportActionMode(new InternalOlderListener()); if (mListener != null) mListener.onItemCheckedStateChanged(mWrapper, position, id, true); } else { list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); } list.setItemChecked(position, true); return true; }
From source file:com.csipsimple.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;// w w w .jav a 2 s.c o m Cursor c = (Cursor) getListAdapter().getItem(position - lv.getHeaderViewsCount()); showDetails(id, c.getString(c.getColumnIndex(SipProfile.FIELD_WIZARD))); }
From source file:org.gnucash.android.ui.accounts.AccountsListFragment.java
/** * De-selects the previously selected item in a ListView. * Only one account entry can be highlighted at a time, so the previously selected * one is deselected. /*from www .ja v a 2s. c o m*/ */ private void deselectPreviousSelectedItem() { if (mSelectedViewPosition >= 0) { ListView lv = getListView(); lv.setItemChecked(mSelectedViewPosition, false); View v = getListView().getChildAt(mSelectedViewPosition - lv.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)); v.setSelected(false); } }
From source file:com.akalipetis.fragment.ActionModeListFragment.java
@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ListView list = getListView(); int choiceMode = list.getChoiceMode(); mLastChoiceMode = choiceMode;// ww w. ja v a 2 s .co m if (choiceMode == ListView.CHOICE_MODE_SINGLE) mLastCheckedItem = list.getCheckedItemPosition(); else mLastCheckedItem = ListView.INVALID_POSITION; if (Build.VERSION.SDK_INT < 11) { list.setItemChecked(mLastCheckedItem, false); list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); list.setLongClickable(false); ((AppCompatActivity) getActivity()).startSupportActionMode(new InternalOlderListener()); list.setItemChecked(position, true); if (mListener != null) mListener.onItemCheckedStateChanged(mWrapper, position, id, true); } else { list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); list.setItemChecked(position, true); } return true; }
From source file:net.tjado.passwdsafe.PasswdSafeListFragmentTree.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 {/*w w w . j a v a 2 s . c o m*/ list.clearChoices(); } if (itsEmptyText.getText().length() == 0) { itsEmptyText.setText(itsIsContents ? R.string.no_records : R.string.no_groups); } } }
From source file:com.fututel.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 ww w.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.flerda.android.honeypad.NoteListFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.checkbox: Integer position = (Integer) v.getTag(R.id.list); if (null != position) { ListView lv = getListView(); int pos = position; boolean isChecked = !lv.isItemChecked(pos); lv.setItemChecked(pos, isChecked); if (!mIsV11) { showMultiPanel();/*from www .ja va2 s . co m*/ } } break; case R.id.btn_multi_delete: { Activity a = getActivity(); ContentResolver cr = a.getContentResolver(); ListView lv = mLV; int deletedCount = 0; /** Badness. Don't loop a delete operation on the UI thread **/ /** We also assume that the ID's and positions are constant **/ for (long id : lv.getCheckItemIds()) { deletedCount += cr.delete(ContentUris.withAppendedId(NotesProvider.CONTENT_URI, id), null, null); } // clear any selections lv.clearChoices(); // update container mContainerCallback.onNoteDeleted(); // show a toast to confirm delete Toast.makeText(a, String.format(getString(R.string.num_deleted), deletedCount, (deletedCount == 1 ? "" : "s")), Toast.LENGTH_SHORT).show(); showMultiPanel(); break; } } }
From source file:com.cloudtask1.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*from w w w . ja v a 2 s . c o m*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } }
From source file:nz.ac.wintec.soit.af5.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//* w ww.ja va 2 s. c om*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } }
From source file:com.ternup.caddisfly.fragment.ResultFragment.java
private void goBack() { FragmentManager fm = getFragmentManager(); try {//from w ww . ja v a 2 s . c om if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); fm.executePendingTransactions(); } else { Fragment fragment = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.executePendingTransactions(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.replace(R.id.container, fragment, "0"); ft.addToBackStack(null); ft.commit(); fm.executePendingTransactions(); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(0, true); drawerList.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } }