SimpleCursorAdapter and Spinner control

by gin_tonic » Thu, 29 Oct 2009 14:42:49 GMT

Sponsored Links

I'm trying to create a very simple application that extract data from
SQL database and populate a spinner control with (for example) product
I found the following example of the code:

String[] from = new String[] { "Product_Name" };

int[] to = new int[] { };

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item, product_cursor, from, to  );



The only thing I couldn't understand what should I put into "to"
array? The spinner is the only control on the form. I tried to find
the answer, but most of the samples use ListView control and put
"" into "to" array



SimpleCursorAdapter and Spinner control

by gin_tonic » Fri, 06 Nov 2009 06:47:06 GMT

 Found the source of the problem and the solution.

1. is predefined UI element for Spinner control and
should be used in 'to' array
2. In this case (using SimpleCursorAdapter) cursor MUST have '_id'
field. If you get data from SQL database and use raw SQL query, it
possible to use the next statement:
    SELECT Product_ID AS _id ...


Sponsored Links

Other Threads

1. Is there a way for an app to constrain 3rd party usage

Apologies in advance if this is an ignorant question.

Is there a way for an app to ensure that it exclusively gets keyboard
input from the bundled keyboard(s)/IMEs?
Is there a way for an app to know which keyboard is in use when
receiving input in a text field?
Is there a way for an app to constrain the set of keyboard choices
(only for itself, not the system as a whole?



2. Testing for memory leaks in kernel driver code

     What tools can we use for testing memory leaks in the android
linux kernel driver code?

Elvis Dowson


3. Could use some help (free game on Galaxy S problem)

4. Which Landscape?

5. how to disable auto screen brightness?

6. Bluetooth headset noise-cancellation activation through android app

7. IOException: SSL handshake failure problem in Eclair