Hi Ricardo,

First, I'm sure others will chime in if this is bad advice, but my understanding is that it is better to use the compatibility package and cursor loaders and a load manager. See http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html and the base CursorAdapter.

That said, from is simply a list of columns in the PROJECTION exposed by the cursor that are of interest to the ListView ids in the to array. This is in order of the two arrays such that the data from from[x] is passed to the view with the id in to[x].

Given the list view row definition:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
              android:layout_width="fill_parent"
              android:layout_height="34dp"
              android:gravity="bottom"
              android:orientation="horizontal">

<TextView xmlns:android="http://schemas.android.com/apk/res/android";
        android:id="@+id/foo"
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:textSize="16dp"
        android:gravity="center_vertical"
        android:paddingLeft="5dip"
        android:singleLine="true"
        />
<TextView xmlns:android="http://schemas.android.com/apk/res/android";
        android:id="@+id/bar"
        android:layout_width="50dp"
        android:layout_height="30dp"
        android:textSize="20dp"
        android:gravity="right|center_vertical"
        android:paddingLeft="5dip"
        android:singleLine="true"
        />
</LinearLayout>

And assuming that you have column1 and column2 in your cursor's projection, and want to map the contents of column1 to the textview foo and column2 to textview bar, from and to would be defined something like:

String[] from =  new String[] { "column1" , "coulmn2"};
int[] to           = new int[] { R.id.foo , R.id.bar };

Clear as mud?

-Ted

On 3/31/2012 9:36 PM, Ricardo Santos wrote:
Hello everyone!

I have in my application, I hace a list view that needs to be populated with data from a database, I have tested my database and my app is handling the data correctly, but I cant populate the list view, I have read about the SimpleCursorAdapter but I cant understand how to use the class, specially the from and to fields, does anyone know how to use it?

  My class is not extending ListActivity, my list view is inside a dialog.

Ricardo
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to