AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'... after making selection
        Posted  
        
            by user244190
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user244190
        
        
        
        Published on 2010-01-29T03:16:45Z
        Indexed on 
            2010/06/02
            18:24 UTC
        
        
        Read the original article
        Hit count: 616
        
android
|android-widget
I am using the following code to set the adapter (SimpleCursorAdapter) for an AutoCompleteTextView
mComment = (AutoCompleteTextView) findViewById(R.id.comment);
    Cursor cComments = myAdapter.getDistinctComments();
    scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1});
    mComment.setAdapter(scaComments);
auto_complete_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
and thi is the xml for the actual control
<AutoCompleteTextView
                        android:id="@+id/comment"
                        android:hint="@string/COMMENT"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:textSize="18dp"/>
The dropdown appears to work correctly, and shows a list of items. When I make a selection from the list I get a sqlite object ('android.database.sqlite.SQLiteCursor@'... ) in the textview. Anyone know what would cause this, or how to resolve this?
thanks
Ok I am able to hook into the OnItemClick event, but the TextView.setText() portion of the AutoCompleteTextView widget is updated after this point. The OnItemSelected() event never gets fired, and the onNothingSelected() event gets fired when the dropdown items are first displayed.
       mComment.setOnItemClickListener( new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter();
            String str = getSpinnerSelectedValue(sca,arg2,"comment");
            TextView txt = (TextView) arg1;
            txt.setText(str);
            Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show();
        }
    });
    mComment.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
            Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show();
        }
    });
Anyone alse have any ideas on how to override the updating of the TextView?
thanks
patrick
© Stack Overflow or respective owner