本文整理匯總了Java中android.support.v4.widget.SimpleCursorAdapter類的典型用法代碼示例。如果您正苦於以下問題:Java SimpleCursorAdapter類的具體用法?Java SimpleCursorAdapter怎麽用?Java SimpleCursorAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SimpleCursorAdapter類屬於android.support.v4.widget包,在下文中一共展示了SimpleCursorAdapter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpCategoriesSpinner
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
private void setUpCategoriesSpinner() {
String[] columns = new String[] { Categories.CATEGORY };
getSupportLoaderManager().restartLoader(1, null, this);
categoriesAdapter = new SimpleCursorAdapter(this, R.layout.spinner_category, null, columns,
new int[] { android.R.id.text1 }, 0);
ArrayAdapter<String> allRecipesAdapter = new ArrayAdapter<String>(this,
R.layout.spinner_category, android.R.id.text1, new String[] {
getString(R.string.all_recipes), getString(R.string.favorites) });
allRecipesAdapter.setDropDownViewResource(R.layout.drop_down_item_category);
categoriesAdapter.setDropDownViewResource(R.layout.drop_down_item_category);
MergeSpinnerAdapter mergeAdapter = new MergeSpinnerAdapter();
mergeAdapter.addAdapter(allRecipesAdapter);
mergeAdapter.addAdapter(categoriesAdapter);
getSupportActionBar().setListNavigationCallbacks(mergeAdapter, this);
}
示例2: setupCursorAdapter
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
private void setupCursorAdapter() {
String[] uiBindFrom = {
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_URI };
int[] uiBindTo = {R.id.tvName, R.id.ivImage};
adapter = new SimpleCursorAdapter(
this,
R.layout.contacts_list_item,
null,
uiBindFrom,
uiBindTo, 0);
}
示例3: showContactListUnsecure
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
private void showContactListUnsecure() {ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null
);
new AlertDialog.Builder(RxPermissionDemoActivity.this)
.setAdapter(
new SimpleCursorAdapter(
RxPermissionDemoActivity.this,
android.R.layout.simple_list_item_1,
cur,
new String[]{ContactsContract.Contacts.DISPLAY_NAME}, new int[]{android.R.id.text1}, 0
),
null
)
.show();
}
示例4: onCreate
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView dictListView = (ListView) findViewById(R.id.dictionary_list_view);
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, null, null, null, null);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.listview_layout, cursor, COLUMNS_TO_BE_FOUND, LAYOUT_ITEMS_TO_FILL, 0);
dictListView.setAdapter(adapter);
registerForContextMenu(dictListView);
}
示例5: onCreate
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addNote(DEFAULT_NOTE_TITLE);
Cursor cursor = getContentResolver().query(NoteProvider.CONTENT_URI, DBOpenHelper.ALL_COLUMNS, null, null, null, null);
String[] from = {DBOpenHelper.NOTE_TEXT};
int[] to = {android.R.id.text1};
CursorAdapter cursorAdapter = new SimpleCursorAdapter(this, android.R.simple_list_item1, cursor, from, to, 0);
ListView list = (ListView) findViewById(android.R.id.list);
list.setAdapter(cursorAdapter);
}
示例6: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Gets the ListView from the View list of the parent activity
mContactsList = (ListView) getActivity().findViewById(R.id.list);
// Gets a CursorAdapter
mCursorAdapter = new SimpleCursorAdapter(
getActivity(),
R.layout.contact_list_item,
null,
FROM_COLUMNS, TO_IDS,
0);
// Sets the adapter for the ListView
mContactsList.setAdapter(mCursorAdapter);
mContactsList.setOnItemClickListener(this);
Log.i("Info", "Adapter set");
// Initializes the loader
getLoaderManager().initLoader(0, null, this);
}
示例7: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
binding = FragmentVideoAllBinding.bind(getView());
facade = VideoFacade.getInstance(getContext());
adapter = new SimpleCursorAdapter(getContext(), R.layout.list_item_image, null,
new String[] {MediaStore.Images.Media.BUCKET_DISPLAY_NAME},
new int[] {R.id.text}, 0) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
VideoCursor wrapper = new VideoCursor(cursor);
ImageView iv = (ImageView) view.findViewById(R.id.image);
iv.setImageBitmap(facade.thumbnail().fetch(wrapper.id(), MediaStore.Video.Thumbnails.MINI_KIND));
}
};
binding.list.setEmptyView(binding.empty);
binding.list.setAdapter(adapter);
Observable.fromCallable(() -> facade.video().fetch())
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(adapter::swapCursor, LogHelper::logError, this::applyEmptyContent);
}
示例8: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
binding = FragmentAudioAlbumsBinding.bind(getView());
facade = AudioFacade.getInstance(getContext());
adapter = new SimpleCursorAdapter(getContext(), R.layout.list_item_album, null,
new String[] {MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ARTIST},
new int[] {R.id.text1, R.id.text2}, 0) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
ImageView iv = (ImageView) view.findViewById(R.id.album_art);
Uri uri = facade.album().albumArtUri(cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Albums._ID)));
Picasso.with(context).load(uri).resizeDimen(R.dimen.image_size, R.dimen.image_size).centerCrop().into(iv);
}
};
binding.list.setEmptyView(binding.empty);
binding.list.setAdapter(adapter);
Observable.fromCallable(() -> facade.album().fetchAlbums())
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(adapter::swapCursor, LogHelper::logError, this::applyEmptyContent);
}
示例9: initData
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
private void initData() {
final DataHelper dataHelper = new DataHelper(getActivity());
mSession = dataHelper.getActiveSessionId();
final String[] from = new String []{
Schema.COL_ID,
Schema.COL_BSSID,
Schema.COL_SSID,
"MAX(" + Schema.COL_LEVEL + ")",
/*Schema.COL_IS_NEW_WIFI,*/
Schema.COL_KNOWN_WIFI,
Schema.COL_CAPABILITIES};
final int[] to = new int [] {
R.id.wifilistfragment_id,
R.id.wifilistfragment_bssid,
R.id.wifilistfragment_ssid,
R.id.wifilistfragment_level,
R.id.wifilistfragment_statusicon,
R.id.wifilistfragment_capabilities};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.wifilistitems, null, from, to, 0);
mAdapter.setViewBinder(new WifiViewBinder());
setListAdapter(mAdapter);
}
示例10: initData
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
/**
*
*/
private void initData() {
final DataHelper dataHelper = new DataHelper(getActivity());
mSession = dataHelper.getActiveSessionId();
final String[] from = new String[] {
Schema.COL_ACTUAL_CELLID,
Schema.COL_OPERATORNAME,
Schema.COL_NETWORKTYPE,
"MAX(" + Schema.COL_STRENGTHDBM + ")"
};
final int[] to = new int[] {
R.id.textViewCellID,
R.id.textViewOperator,
R.id.textViewNetworkType,
R.id.textViewStrenghtDbm
};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.celllistitems, null, from, to, 0);
mAdapter.setViewBinder(new NetworkTypeDescriptionViewBinder());
setListAdapter(mAdapter);
}
示例11: onCreate
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.setDrawerShadow(android.R.color.white, GravityCompat.END);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList.setOnItemClickListener(this);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
if (mToolbar != null){
setSupportActionBar(mToolbar);
}
mDrawerToggle = new ActionBarDrawerToggle(
this, mDrawerLayout, mToolbar,
R.string.app_name, R.string.app_name
);
mDrawerLayout.addDrawerListener(mDrawerToggle);
setDisplayHomeAsUpEnabled(true);
mDrawerAdapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.list_item_group, null, new String[]{ProviderConsts.GroupTbl.NAME}, new int[]{android.R.id.text1}, 0);
mDrawerList.setAdapter(mDrawerAdapter);
}
示例12: populateContactsSpinner
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
private void populateContactsSpinner(View root) {
// Query for list of contacts
String accountName = getString(R.string.account_name);
String accountType = getString(R.string.account_type);
Cursor cursor = ContactsUtils.queryRawContacts(getActivity(), accountName, accountType);
// Create adapter to display contacts in spinner
String[] adapterCols = new String[] { ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY };
int[] adapterRowViews = new int[] { android.R.id.text1 };
mContactAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, cursor, adapterCols, adapterRowViews, 0);
// Specify the layout to use when the list of choices appears
mContactAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
mContactSpinner.setAdapter(mContactAdapter);
// If a contact id is available set the spinner selection:
String gwid = gift.getGiftwiseId();
if (gwid == null) {
mContactSpinner.setSelection(0);
} else {
selectSpinnerItemByContactId(gwid);
}
}
示例13: onCreateView
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_community, container, false);
listLogs=(ListView)rootView.findViewById(R.id.listLogs);
Actionbaractvitys actionbaractvitys=new Actionbaractvitys(getActivity(), R.drawable.ic_communities);
Db=(new DBopenHelperLogs(this.getActivity())).getReadableDatabase();
Cursor c=Db.query("Lap",
new String[]{"id as _id","Tanggal"},
null,
null,
null,
null,
"Tanggal ASC");
//menampilkan ke layout
listAdapter=new SimpleCursorAdapter(this.getActivity(),R.layout.list_logs,c,
new String[]{"_id","Tanggal"}
,new int[]{R.id.TvId,R.id.TvTanggal});
listLogs.setAdapter(listAdapter);
Db.close();
return rootView;
}
示例14: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
activity = (PlaceActivity)getActivity();
// Create a new SimpleCursorAdapter that displays the name of each nearby
// venue and the current distance to it.
adapter = new SimpleCursorAdapter(
activity,
android.R.layout.two_line_list_item,
cursor,
new String[] {PlacesContentProvider.KEY_NAME, PlacesContentProvider.KEY_DISTANCE},
new int[] {android.R.id.text1, android.R.id.text2},
0);
// Allocate the adapter to the List displayed within this fragment.
setListAdapter(adapter);
// Populate the adapter / list using a Cursor Loader.
getLoaderManager().initLoader(0, null, this);
}
示例15: onLoadFinished
import android.support.v4.widget.SimpleCursorAdapter; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
((SimpleCursorAdapter) this.getListAdapter()).swapCursor(cursor);
ListView listView = getListView();
String fdroid = loader.getContext().getPackageName();
for (int i = 0; i < listView.getCount() - 1; i++) {
Cursor c = ((Cursor) listView.getItemAtPosition(i + 1));
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID));
if (TextUtils.equals(packageName, fdroid)) {
listView.setItemChecked(i, true); // always include FDroid
} else {
for (String selected : FDroidApp.selectedApps) {
if (TextUtils.equals(packageName, selected)) {
listView.setItemChecked(i + 1, true);
}
}
}
}
if (isResumed()) {
setListShown(true);
} else {
setListShownNoAnimation(true);
}
}