AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'… after making selection

前端 未结 4 1743
春和景丽
春和景丽 2021-02-08 10:25

I am using the following code to set the adapter (SimpleCursorAdapter) for an AutoCompleteTextView

mComment = (AutoCompleteTextView) findViewById(R.id.comment);
         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-08 10:51

    When I make a selection from the list I get a sqlite object ('android.database.sqlite.SQLiteCursor@'... ) in the textview.

    You do not say what this "textview" is or how it relates to the Spinner.

    I am going to take an educated guess and assume that you are simply assigning the selected item out of the Spinner into the TextView.

    The selected item from a Spinner using a SimpleCursorAdapter is a Cursor, pointing at the row the user selected. The toString() implementation of Cursor will give you something akin to android.database.sqlite.SQLiteCursor@ depending on where the Cursor came from.

    More likely, you are going to want to call getString() on that Cursor, to retrieve some column value, and assign it to the TextView in question.

提交回复
热议问题