當我使用cursor.moveToNext();在我的代碼然後應用程序強制整理活動當我向下滾動底部,但是當我刪除cursor.moveToNext();它正常工作?光標代碼給出錯誤?
class NoteHolder {
private Button b1 = null;
private Button b2 = null;
private Button b3 = null;
NoteHolder(View row) {
b1 = (Button) row.findViewById(R.id.one);
b2 = (Button) row.findViewById(R.id.two);
b3 = (Button) row.findViewById(R.id.three);
}
void populateFrom(Cursor c, NoteHelper helper) {
b1.setText(helper.getNote(c));
c.moveToNext();
b2.setText(helper.getNote(c));
c.moveToNext();
b3.setText(helper.getNote(c));
}
}
錯誤是
ERROR/AndroidRuntime(622): FATAL EXCEPTION: main
ERROR/AndroidRuntime(622): android.database.CursorIndexOutOfBoundsException: Index 16 requested, with a size of 16
ERROR/AndroidRuntime(622): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
ERROR/AndroidRuntime(622): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
ERROR/AndroidRuntime(622): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
ERROR/AndroidRuntime(622): at com.example.buttontest.ButtonTest$NoteHelper.getNote(ButtonTest.java:141)
ERROR/AndroidRuntime(622): at com.example.buttontest.ButtonTest$NoteHolder.populateFrom(ButtonTest.java:105)
ERROR/AndroidRuntime(622): at com.example.buttontest.ButtonTest$NoteAdapter.bindView(ButtonTest.java:71)
ERROR/AndroidRuntime(622): at android.widget.CursorAdapter.getView(CursorAdapter.java:186)
ERROR/AndroidRuntime(622): at android.widget.AbsListView.obtainView(AbsListView.java:1294)
ERROR/AndroidRuntime(622): at android.widget.ListView.makeAndAddView(ListView.java:1727)
ERROR/AndroidRuntime(622): at android.widget.ListView.fillDown(ListView.java:652)
ERROR/AndroidRuntime(622): at android.widget.ListView.fillGap(ListView.java:623)
ERROR/AndroidRuntime(622): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
ERROR/AndroidRuntime(622): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2485)
ERROR/AndroidRuntime(622): at android.os.Handler.handleCallback(Handler.java:587)
ERROR/AndroidRuntime(622): at android.os.Handler.dispatchMessage(Handler.java:92)
ERROR/AndroidRuntime(622): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(622): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(622): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(622): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(622): at dalvik.system.NativeStart.main(Native Method)
我的數據庫有12個值我使用表格佈局列表視圖,但在第二排它再次開始從數據庫中顯示第二值,並告訴我警報部隊完成活動當我到達下來底部滾動... –
不能得到你完全可以你更具體的關於你的問題... –
我有三個按鈕在表格佈局和我的數據庫有12個值我想設置文本按鈕從數據庫1 - >這段代碼給出第一行的第一個三個值,第二行開始設置第一行的第二個值的按鈕上的文本,依此類推...... 2->當我使用moveToNext();與我的代碼,當我移動查看底部行它將顯示強制整理活動,當我不使用moveToNext();那麼滾動將是好的 –