1. Download our Official Android App: Forums for Android!

Apps SimpleCursorAdapter problem

Discussion in 'Android Development' started by assistant, Feb 20, 2011.

  1. assistant

    assistant Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    9
    Joined:
    Feb 20, 2011

    Feb 20, 2011
    9
    0
    5
    Hi,

    Selected data from SQLite database is placed in a cursor.

    I have autocomplete textview in which I want to show only certain columns from cursor (e.g. first and last name).

    I've managed to do that, but when I select an item from drop down list from autocomplete textview, it's not showing first and last name as a string (in a autocomplete textbox) but this:

    android.database.sqlite.SQLiteCursor@43767ab8.

    Code (Text):
    1.  
    2. .....
    3.  
    4. Cursor cursor = db.query("tblUsers", null, null, null, null, null, null);
    5.        
    6.          
    7. String[] from = new String[] { "name", "lastname" };
    8. int[] to = new int[] { android.R.id.text1, android.R.id.text2};
    9.  
    10. textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_users);
    11.            
    12. adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, cursor, from, to);
    13.            
    14.            
    15. textView.setAdapter(adapter);
    16.  
    17. .....
    18.  
    19.  
    How to solve this? Please help.

    Thanks in advance!

    Best regards,
    I. F.
     

    Advertisement

Share This Page

Loading...