Questions tagged [simplecursoradapter]

A basic adapter to map columns from a cursor(of Database) to TextViews or ImageViews defined in an XML layout file.

A basic adapter to map columns from a cursor(of Database) to TextViews or ImageViews defined in an XML layout file. Although the SimpleCursorAdapter is a basic adapter it can implement a more complex data-views binding by assigning it a ViewBinder instance to supplement the binding logic.


From the documentation of the SimpleCursorAdapter class:

An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. You can specify which columns you want, which views you want to display the columns, and the XML file that defines the appearance of these views. Binding occurs in two phases. First, if a SimpleCursorAdapter.ViewBinder is available, setViewValue(android.view.View, android.database.Cursor, int) is invoked. If the returned value is true, binding has occured. If the returned value is false and the view to bind is a TextView, setViewText(TextView, String) is invoked. If the returned value is false and the view to bind is an ImageView, setViewImage(ImageView, String) is invoked. If no appropriate binding can be found, an IllegalStateException is thrown. If this adapter is used with filtering, for instance in an AutoCompleteTextView, you can use the SimpleCursorAdapter.CursorToStringConverter and the FilterQueryProvider interfaces to get control over the filtering process. You can refer to convertToString(android.database.Cursor) and runQueryOnBackgroundThread(CharSequence) for more information.

Tag Usage:

972 questions
130
votes
12 answers

Using the recyclerview with a database

Currently there is no default implementation of RecyclerView.Adapter available. May be with the official release, Google will add it. Since there is no support for CursorAdapter with the RecyclerView currently, how can we use a RecyclerView with a…
LostPuppy
  • 2,471
  • 4
  • 23
  • 34
66
votes
6 answers

How to set Spinner Default by its Value instead of Position?

I have 1-50 records in the database. I am fetching those data using cursor and set those values to Spinner using Simple Cursor Adapter. Now what i need is i want to set one value say 39th value as default. But not by its position i want to set by…
vinothp
  • 9,939
  • 19
  • 61
  • 103
54
votes
7 answers

android listview item height

Why when i use SimpleCursorAdapter for ListView i have items height in ListView like this - (My code based on this) But when using arrays Listview items have big height (I learn listview based on this) Row layout for item listview is
olegi
  • 2,051
  • 3
  • 16
  • 9
38
votes
2 answers

Get selected item from ListView bound with SimpleCursorAdapter

I'm brand new to Android development... coming from iPhone and .Net background. I've seen very similar questions to this one, but none of them dealt with the SimpleCursorAdapter. I have a basic ListActivity which uses a Cursor to bind data from a…
GendoIkari
  • 11,734
  • 6
  • 62
  • 104
34
votes
2 answers

How to read an SQLite DB in android with a cursorloader?

I'm setting up my app so that people can create groups of their friends. When a group is created, it writes 2 tables to the SQL database. The first table has a group name and a group id. The second table has 2 columns, a group id and a user id. This…
30
votes
1 answer

SimpleCursorAdapter deprecated in API version 15?

SimpleCursorAdapter deprecates one of its constructors with the following comment: Deprecated. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even…
vogella
  • 24,574
  • 4
  • 29
  • 26
30
votes
3 answers

How to insert extra elements into a SimpleCursorAdapter or Cursor for a Spinner?

I have a Spinner which is to show a list of data fetched from database. The data is returned to a cursor from query, and the cursor gets passed to spinner's SimpleCursorAdapter. It is working fine as such, but I want to insert another item on top of…
elto
  • 447
  • 2
  • 9
  • 13
22
votes
2 answers

Converting an ArrayAdapter to CursorAdapter for use in a SearchView

How can I convert an ArrayAdapter of static data into a CursorAdapter for using Suggestion Listener in SearchView? I have constructed the ArrayAdapter from static data (allString) ArrayAdapter searchAdapter = new…
22
votes
3 answers

SimpleCursorTreeAdapter and CursorLoader for ExpandableListView

I am trying to asynchronously query a provider by using a CursorLoader with a SimpleCursorTreeAdapter Here is my Fragment class which implements the CursorLoader public class GroupsListFragment extends ExpandableListFragment implements …
18
votes
8 answers

how to get a list item position by clicking the button inside it?

actually I've read some previous questions about this... this is the code that I use auto = (ListView)findViewById(R.id.auto); String[] projection = new String[]…
BolbazarMarme
  • 1,221
  • 2
  • 13
  • 25
18
votes
2 answers

Android: Using SimpleCursorAdapter to get Data from Database to ListView

I am programming an android app that should use a database to store data and read from it. Using this tutorial (on archive.org) I got the app to create a database and I'm able to create new entries, however, I don't know, how to read the database to…
NiPfi
  • 1,710
  • 3
  • 18
  • 28
17
votes
4 answers

how do i create a custom cursor adapter for a listview for use with images and text?

Hi want to create a custom cursor adapter so I can display an image with 2 lines of text. I have had some trouble understanding the custom cursor adapters but I do not understand how to add an imageview to be filled from the path in my database.
waa1990
  • 2,365
  • 9
  • 27
  • 33
17
votes
1 answer

how to display contacts in a listview in Android for Android api 11+

I'm sorry if this looks like the same question a million times...but a google search for this provides no results, just a bunch of outdated tutorials using managedQuery and other deprecated solutions... I went through the android developer training…
Terence Chow
  • 10,755
  • 24
  • 78
  • 141
16
votes
2 answers

Android: Issue with newView and bindView in custom SimpleCursorAdapter

I created a custom SimpleCursorAdapter from one of the only example I found. When my ListActivity is called, newView and bindView are called for every of my DB entry, and called again for every entry. I've got a few questions: -is the example right…
jul
  • 36,404
  • 64
  • 191
  • 318
16
votes
1 answer

Modifying SimpleCursorAdapter's data

I'm working on a TV Guide app which uses a ListActivity showing the TV shows for one channel / one day at a time. I'm using a RelativeLayout for the ListView items and I want the ListView to look something like this: 07:00 The Breakfast Show …
Squonk
  • 48,735
  • 19
  • 103
  • 135
1
2 3
64 65