Why wont my ListView onListItemClick return the ListView as a text value?
<p>I apologize if this is total newb on my behalf.  I am brand new to android programming and I am frustrated as hell!  I have looked and tried so many examples on this but they all seem to be yielding the same result.</p>

<p>The bottom line is... i have a listview of contact names.  when i click on a name I want the toast to repeat their name.  But instead of toasting their name I keep getting values like "android.content.ContentResolver$CursorWrapperInner@40571e90" where I would expect to see "John Smith"</p>

<pre><code>import android.app.ListActivity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;

public class ContactListOne extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contact_list_one);
        populateContactListOne();
   }

    private Cursor getContacts()
    {
        // Run query
        Uri uri = ContactsContract.Contacts.CONTENT_URI;
        String[] projection = new String[] {
                ContactsContract.Contacts._ID,
                ContactsContract.Contacts.DISPLAY_NAME
        };
        return managedQuery(uri, projection, null, null, null);
    }

    private void populateContactListOne() {
        Cursor cursor = getContacts();
        //Build adapter with contact info

        String[] fields = new String[] {

                ContactsContract.Contacts.DISPLAY_NAME
        };
        int[] to = new int[]{

                R.id.contactname
        };

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.contact_list_one_rows, cursor, fields, to);

        setListAdapter(adapter);

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);

        String keyword =  getListAdapter().getItem(position).toString();

        Toast.makeText(this, "You selected: " + keyword,Toast.LENGTH_LONG).show();
    }
}
</code></pre>

<p>Here are my 2 xml layouts:</p>

<p>contact_list_one:
    </p>

<pre><code>    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent" &gt;

        &lt;ListView android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:id="@android:id/list"

                  /&gt;



    &lt;/LinearLayout&gt;
</code></pre>

<p>contact_list_one_rows:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;



                   &lt;TextView 
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:textAppearance="?android:attr/textAppearanceMedium"
                  android:id="@+id/contactname"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:padding="7dip"
                  &gt;
                  &lt;/TextView&gt;
</code></pre>

<p>----------------------------------update------------------------------------------</p>

<p>I am not sure how clean this is... or exactly why it works differently.  But i found an example somewhere on the web it was outdated using an old version of android... but it seems to work.    Here is how I changed my code, by all means if someone can explain to me why this works differently I would love the explanation :)</p>

<pre><code>import android.app.ListActivity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;




public class ContactListOne extends ListActivity {

    private static final int NEW_RULE_CONTACT=1;

    private SimpleCursorAdapter adapter;

    private RulesDbAdapter mDbHelper;
    private ListView wtf;




    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contact_list_one);
        mDbHelper = new RulesDbAdapter(this);



        mDbHelper.open();

        // Obtain handles to UI objects



      Cursor cursor = getContacts();
        //Build adapter with contact info



        String[] fields = new String[] {

                ContactsContract.Contacts.DISPLAY_NAME
        };
        int[] to = new int[]{

                R.id.contactname
        };

        adapter = new SimpleCursorAdapter(this, R.layout.contact_list_one_rows, cursor, fields, to);

        setListAdapter(adapter);

        mDbHelper.close();
    }


    private Cursor getContacts()
    {
        // Run query
        Uri uri = ContactsContract.Contacts.CONTENT_URI;
        String[] projection = new String[] {
                ContactsContract.Contacts._ID,
                ContactsContract.Contacts.DISPLAY_NAME
        };
        String notInList = mDbHelper.createContactNotInList();



        String selection =  ContactsContract.Contacts.DISPLAY_NAME + " != '' AND " + ContactsContract.Contacts.LOOKUP_KEY + notInList ;


        String[] selectionArgs = null;
        String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";


        return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
    }



    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);


        Cursor cursor = (Cursor) adapter.getItem(position);
        String selection = cursor.getString(1);
        Toast.makeText(this, selection,Toast.LENGTH_LONG).show();   



    }



}
</code></pre>
