本文整理了Java中android.widget.ListView.getCheckedItemIds()
方法的一些代码示例,展示了ListView.getCheckedItemIds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.getCheckedItemIds()
方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:getCheckedItemIds
暂无
代码示例来源:origin: stackoverflow.com
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
ViewHolder holder = (ViewHolder) v.getTag();
holder.storyCheckBox.setChecked(false);
holder.story.setTextColor(Color.LTGRAY);
long [] checkedIds = l.getCheckedItemIds();
if (checkedIds != null) {
for (int i = 0; i < checkedIds.length; i++) {
if (checkedIds[i] == getListAdapter().getItemId(position)) {
holder.storyCheckBox.setChecked(true);
holder.story.setTextColor(Color.WHITE);
break;
}
}
}
}
代码示例来源:origin: andforce/iBeebo
private void remove() {
Set<String> set = new HashSet<String>();
long[] ids = listView.getCheckedItemIds();
for (long id : ids) {
set.add(String.valueOf(id));
}
accountList = AccountDao.removeAndGetNewAccountList(set);
listAdapter.notifyDataSetChanged();
}
代码示例来源:origin: openbmap/radiocells-scanner-android
@Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
final int id = (modeView.getCheckedItemIds().length > 0 ? (int) modeView.getCheckedItemIds()[0] : -1);
final boolean result = (handler.onItemLongClick(item.getItemId(),
modeView.getCheckedItemPosition(), id));
if (result) {
activeMode.finish();
}
return(result);
}
代码示例来源:origin: andforce/iBeebo
@Override
protected void onPreExecute() {
super.onPreExecute();
long[] ids = getListView().getCheckedItemIds();
for (long id : ids) {
set.add(String.valueOf(id));
}
}
代码示例来源:origin: stackoverflow.com
ListView mListView = getListView();
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.item_delete:
nr = 0;
Long[] longConverts = new Long(mListView.getCheckedItemIds());
private List<Long> itemids = new ArrayList<Long>(Arrays.asList(longConverts));
for(int i=0;i<itemids.size();i++){
mListView.remove(itemids.get(i));
mAdapter.clearSelection();
// TODO app mAdapter.removeSelection(position);
mode.finish();
}
return true;
}
代码示例来源:origin: arminha/worldclockwidget
private void editClock() {
long id = getListView().getCheckedItemIds()[0];
Intent intent = new Intent(getActivity(), EditClockActivity.class);
intent.putExtra(Clocks._ID, id);
startActivityForResult(intent, 0);
}
代码示例来源:origin: andforce/iBeebo
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_remove) {
SparseBooleanArray positions = getListView().getCheckedItemPositions();
long[] ids = getListView().getCheckedItemIds();
removeItem(positions, ids, mode);
return true;
}
return false;
}
代码示例来源:origin: arminha/worldclockwidget
private void deleteSelectedItems() {
long[] itemIds = getListView().getCheckedItemIds();
Uri baseUri = Clocks.CONTENT_URI;
ContentResolver resolver = getActivity().getContentResolver();
for (long id : itemIds) {
resolver.delete(ContentUris.withAppendedId(baseUri, id), null, null);
}
sendWidgetRefresh(getActivity());
}
代码示例来源:origin: arminha/worldclockwidget
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
long[] checked = getListView().getCheckedItemIds();
if (checked.length > 0) {
if (mMode == null) {
mMode = getSherlockActivity().startActionMode(new ModeCallback());
}
CharSequence format = getResources().getText(R.string.n_selcted_format);
mMode.setTitle(MessageFormat.format(format.toString(), checked.length));
mMode.invalidate();
} else {
if (mMode != null) {
mMode.finish();
}
}
}
});
代码示例来源:origin: arminha/worldclockwidget
private void moveSelected(MoveTarget target) {
long id = getListView().getCheckedItemIds()[0];
WorldClock.Clocks.move(getActivity(), id, target);
sendWidgetRefresh(getActivity());
}
代码示例来源:origin: stackoverflow.com
long[] selected = mListView.getCheckedItemIds();
if (selected.length > 0) {
for (long id: selected) {
代码示例来源:origin: stackoverflow.com
@Override
public void onClick(View v) {
long[] checkedIds = listView.getCheckedItemIds();
for(long id : checkedIds)
database.deleteName(id);
代码示例来源:origin: arminha/worldclockwidget
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAdapter.changeCursor(data);
// The list should now be shown.
if (isResumed()) {
setListShown(true);
} else {
setListShownNoAnimation(true);
}
if (mMode != null) {
if (IS_GINGERBREAD) {
// update checked item after move
ListView list = getListView();
long[] ids = list.getCheckedItemIds();
if (ids.length == 1) {
long checkedId = ids[0];
for (int i = 0; i < list.getCount(); i++) {
long id = list.getAdapter().getItemId(i);
list.setItemChecked(i, checkedId == id);
}
}
}
mMode.invalidate();
}
}
代码示例来源:origin: arminha/worldclockwidget
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
MenuItem editItem = menu.findItem(R.id.menu_edit);
MenuItem upItem = menu.findItem(R.id.menu_up);
MenuItem downItem = menu.findItem(R.id.menu_down);
boolean oneSelected = getListView().getCheckedItemIds().length == 1;
boolean reorderEnabled = !mAutoSortClocks && oneSelected && getListView().getCount() > 1;
boolean changed = setVisible(editItem, oneSelected);
changed = changed || setVisible(upItem, reorderEnabled);
changed = changed || setVisible(downItem, reorderEnabled);
if (changed) {
// fixes entries in the overflow menu
mode.invalidate();
}
return changed;
}
内容来源于网络,如有侵权,请联系作者删除!