android.database.sqlite.SQLiteCursor@435b9ba0 [英] android.database.sqlite.SQLiteCursor@435b9ba0
问题描述
我收到来自返回文本android.database.sqlite.SQLiteCursor@435b9ba0一spinner.getSelectedItem()。toString()方法调用。我不知道为什么。微调器绑在SimpleCursorAdapter。
I am getting the text 'android.database.sqlite.SQLiteCursor@435b9ba0' returned from a spinner.getSelectedItem().toString() call. I'm not sure why. The spinner is tied to a SimpleCursorAdapter.
下面是code
cCategories = (Cursor) myAdapter.getAllCategories();
this.startManagingCursor(cCategories);
SimpleCursorAdapter scaCategories = new SimpleCursorAdapter(this, R.layout.track_category_item,cCategories,new String[] {DBAdapter.KEY_CATEGORIES_NAME},new int[]{R.id.text1});
scaCategories.setDropDownViewResource(R.layout.track_category_dropdown_item);
mCatSpinner = (Spinner) findViewById(R.id.thecategory);
mCatSpinner.setAdapter(scaCategories);
if(mCatSpinner.isSelected() != true) {
mCatSpinner.setSelection(0);
}
和XML track_category_item.xml
and the xml track_category_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:ellipsize="marquee"
android:singleLine="true">
</TextView>
track_category_dropdown_item.xml
track_category_dropdown_item.xml
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee" />
微调器XML看起来像这样
The spinner xml looks like this
<Spinner
android:id="@+id/thecategory"
android:prompt="@string/SELECT_CATEGORY"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="15px"
android:layout_y="133px" >
</Spinner>
和返回光标
public Cursor getAllCategories()
{
return db.query(DATABASE_CATEGORIES_TABLE, new String[] {
KEY_CATEGORIES_ROWID,
KEY_CATEGORIES_NAME,
KEY_CATEGORIES_DEFAULT},
null,
null,
null,
null,
null);
}
的微调似乎正常工作。当我试图挽救这就是被作为使用spinner.getSelectedItem()所选项目的价值。的toString()。
The spinner appears to work properly. When I try to save this is what is passed as the value of the selected item using spinner.getSelectedItem().toString().
任何人看到什么blatently错在这里。不知道该怎么做。
Anyone see anything blatently wrong here. not sure what to do.
谢谢 帕特里克
推荐答案
您code正在为你写的。 微调
是适配器视图
。你把它连接到该适配器是一个 SimpleCursorAdapter
。这意味着,所选择的项目是光标
(定位在游标的结果集对应于用户的选择的项目)。 光标
的的默认实现的toString()
,返回类似 android.database。 sqlite.SQLiteCursor@435b9ba0
。
Your code is working as you wrote it. Spinner
is an AdapterView
. The adapter you connected it to is a SimpleCursorAdapter
. This means that the selected item is a Cursor
(positioned at the item in the Cursor's result set corresponding with the user's choice). Cursor
has the default implementation of toString()
, which returns something like android.database.sqlite.SQLiteCursor@435b9ba0
.
既然你没有告诉我们您正在尝试做什么,这是不可能准确地进一步劝你。不管是什么,你要保存,然而,需要被拉出光标
你获得 getSelectedItem()
Since you didn't tell us what you are trying to do, it is impossible to accurately advise you further. Whatever it is you want to save, however, needs to be pulled out of the Cursor
you get from getSelectedItem()
.
这篇关于android.database.sqlite.SQLiteCursor@435b9ba0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!