0
我想調整我的查詢到我的微調對象有一些麻煩,我得到的錯誤列爲標題。這裏是它崩潰的代碼部分:微調不是一個可以通過這個SimpleCursorAdapter的界限(sp)的視圖
Spinner classDropDown = (Spinner) this.findViewById(R.id.classDropDown);
int[] to = new int[] { R.id.classDropDown };
String[] classFields = new String[] { "className" };
SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.main, cursor, classFields, to);
cursorAdapter.setDropDownViewResource(R.id.classDropDown);
classDropDown.setAdapter(cursorAdapter);
我有一個問題,光標未被填充,但現在修復。有人可以幫我調試這個問題嗎?
編輯:我認爲我的問題是「to」字段。這應該是什麼?
編輯2:另外,這裏是旋轉器對象中的XML:
<Spinner
android:id="@+id/classDropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
編輯3:我已修正上述以反映固定代碼。這解決了這個問題。我沒有收到錯誤信息,但我也沒有在微調器中顯示任何內容。
好的,所以遊標必須返回「from」和「to」字段中相同數量的字段,以及我猜測?此外,你認爲適當的資源ID是什麼意思?最後,如果我只是填充微調框,那麼將它用於「到」字段不是問題嗎?或者我需要一些額外的TextField嗎? – Organiccat
不,你可以返回你想要的任何額外的光標。它必須有一個_id列,但不必顯示它,它只是被框架使用。所有必須匹配的是數字,如果datafields.in中的from和資源id的數量。(在當然需要的數據字段在你的光標中)。 – Barak