本文整理了Java中android.widget.SimpleCursorAdapter.getCursor()
方法的一些代码示例,展示了SimpleCursorAdapter.getCursor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleCursorAdapter.getCursor()
方法的具体详情如下:
包路径:android.widget.SimpleCursorAdapter
类名称:SimpleCursorAdapter
方法名:getCursor
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testSwapCursor() {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
Cursor cursor = setUpDatabase();
adapter.swapCursor(cursor);
assertThat(adapter.getCursor()).isSameAs(cursor);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testChangeCursor() {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
Cursor cursor = setUpDatabase();
adapter.changeCursor(cursor);
assertThat(adapter.getCursor()).isSameAs(cursor);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSwapCursorToNull() {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
Cursor cursor = setUpDatabase();
adapter.swapCursor(cursor);
adapter.swapCursor(null);
assertThat(adapter.getCursor()).isNull();
}
代码示例来源:origin: ardovic/Open-Source-Android-Weather-App
@Override
protected void onDestroy() {
super.onDestroy();
if (mAdapter.getCursor() != null) {
mAdapter.getCursor().close();
}
database.close();
//mFetchThreadData.clearQueue();
}
代码示例来源:origin: google/ringdroid
private void startRingdroidEditor() {
Cursor c = mAdapter.getCursor();
int dataIndex = c.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
String filename = c.getString(dataIndex);
try {
Intent intent = new Intent(Intent.ACTION_EDIT, Uri.parse(filename));
intent.putExtra("was_get_content_intent", mWasGetContentIntent);
intent.setClassName( "com.ringdroid", "com.ringdroid.RingdroidEditActivity");
startActivityForResult(intent, REQUEST_CODE_EDIT);
} catch (Exception e) {
Log.e("Ringdroid", "Couldn't start editor");
}
}
代码示例来源:origin: google/ringdroid
private Uri getUri(){
//Get the uri of the item that is in the row
Cursor c = mAdapter.getCursor();
int uriIndex = getUriIndex(c);
if (uriIndex == -1) {
return null;
}
String itemUri = c.getString(uriIndex) + "/" +
c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media._ID));
return (Uri.parse(itemUri));
}
代码示例来源:origin: oVirt/moVirt
private void setList() {
listHosts.setAdapter(hostsAdapter);
listHosts.setOnItemClickListener((parent, view, position, id) -> {
Cursor cursor = hostsAdapter.getCursor();
if (cursor != null && cursor.moveToPosition(position)) {
selectedHost = new Host();
selectedHost.initFromCursor(cursor);
buttonMigrateToSelected.setEnabled(true);
}
});
}
代码示例来源:origin: google/ringdroid
private void onDelete() {
Cursor c = mAdapter.getCursor();
int dataIndex = c.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
String filename = c.getString(dataIndex);
int uriIndex = getUriIndex(c);
if (uriIndex == -1) {
showFinalAlert(getResources().getText(R.string.delete_failed));
return;
}
if (!new File(filename).delete()) {
showFinalAlert(getResources().getText(R.string.delete_failed));
}
String itemUri = c.getString(uriIndex) + "/" +
c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media._ID));
getContentResolver().delete(Uri.parse(itemUri), null, null);
}
代码示例来源:origin: google/ringdroid
private void assignRingtoneToContact() {
Cursor c = mAdapter.getCursor();
int dataIndex = c.getColumnIndexOrThrow(Contacts._ID);
String contactId = c.getString(dataIndex);
dataIndex = c.getColumnIndexOrThrow(Contacts.DISPLAY_NAME);
String displayName = c.getString(dataIndex);
Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, contactId);
ContentValues values = new ContentValues();
values.put(Contacts.CUSTOM_RINGTONE, mRingtoneUri.toString());
getContentResolver().update(uri, values, null, null);
String message =
getResources().getText(R.string.success_contact_ringtone) +
" " +
displayName;
Toast.makeText(this, message, Toast.LENGTH_SHORT)
.show();
finish();
return;
}
代码示例来源:origin: google/ringdroid
private void setAsDefaultRingtoneOrNotification(){
Cursor c = mAdapter.getCursor();
// If the item is a ringtone then set the default ringtone,
// otherwise it has to be a notification so set the default notification sound
if (0 != c.getInt(c.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_RINGTONE))){
RingtoneManager.setActualDefaultRingtoneUri(
RingdroidSelectActivity.this,
RingtoneManager.TYPE_RINGTONE,
getUri());
Toast.makeText(
RingdroidSelectActivity.this,
R.string.default_ringtone_success_message,
Toast.LENGTH_SHORT)
.show();
} else {
RingtoneManager.setActualDefaultRingtoneUri(
RingdroidSelectActivity.this,
RingtoneManager.TYPE_NOTIFICATION,
getUri());
Toast.makeText(
RingdroidSelectActivity.this,
R.string.default_notification_success_message,
Toast.LENGTH_SHORT)
.show();
}
}
代码示例来源:origin: google/ringdroid
@Override
public void onCreateContextMenu(ContextMenu menu,
View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
Cursor c = mAdapter.getCursor();
String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
menu.setHeaderTitle(title);
menu.add(0, CMD_EDIT, 0, R.string.context_menu_edit);
menu.add(0, CMD_DELETE, 0, R.string.context_menu_delete);
// Add items to the context menu item based on file type
if (0 != c.getInt(c.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_RINGTONE))) {
menu.add(0, CMD_SET_AS_DEFAULT, 0, R.string.context_menu_default_ringtone);
menu.add(0, CMD_SET_AS_CONTACT, 0, R.string.context_menu_contact);
} else if (0 != c.getInt(c.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_NOTIFICATION))) {
menu.add(0, CMD_SET_AS_DEFAULT, 0, R.string.context_menu_default_notification);
}
}
代码示例来源:origin: google/ringdroid
private void confirmDelete() {
Cursor c = mAdapter.getCursor();
String artist = c.getString(c.getColumnIndexOrThrow(
MediaStore.Audio.Media.ARTIST));
代码示例来源:origin: GeoODK/collect
private void showUnsent() {
mShowUnsent = true;
Cursor c = mShowUnsent ? getUnsentCursor() : getAllCursor();
Cursor old = mInstances.getCursor();
try {
mInstances.changeCursor(c);
} finally {
if (old != null) {
old.close();
this.stopManagingCursor(old);
}
}
getListView().invalidate();
}
代码示例来源:origin: GeoODK/collect
private void showAll() {
mShowUnsent = false;
Cursor c = mShowUnsent ? getUnsentCursor() : getAllCursor();
Cursor old = mInstances.getCursor();
try {
mInstances.changeCursor(c);
} finally {
if (old != null) {
old.close();
this.stopManagingCursor(old);
}
}
getListView().invalidate();
}
内容来源于网络,如有侵权,请联系作者删除!