0

在地圖上的標記膠帶時,我有此代碼來顯示一個AlertDialog:[奇怪的問題] CursorIndexOutOfBoundsException:索引-1請求,將尺寸爲4

protected boolean onTap(int index) { 
      db = openHelper.getWritableDatabase(); 

      String[] result_columns = new String[] {COL_DESCRI}; 

      Cursor cur = db.query(true, TABLE_COORD, result_columns, 
      null, null, null, null, null, null); 

      cur.moveToPosition(index-1); 
       String description = cur.getString(cur.getColumnIndexOrThrow(COL_DESCRI)); 

       AlertDialog.Builder dialog = new AlertDialog.Builder(Geo.this); 
       dialog.setTitle("Infos."); 
       dialog.setMessage(description); 
       dialog.setPositiveButton("OK", new OnClickListener() {  
        @Override 
        public void onClick(DialogInterface dialog, int which) { 
         dialog.dismiss(); 
        } 
       }); 
       dialog.show(); 



      cur.close(); 
      db.close(); 

      return true; 
     } 

的問題是,4 3個標記由於缺點,有一個是強制關閉應用程序。他可能是那個錯誤的問題?我製作了cur.moveToPosition(index-1);,總是出現同樣的問題。 感謝您的幫助。

回答

0

您是否嘗試過使用cur.moveToNext()?它適用於我

+0

我必須使它在一個循環,如果我這樣做,我會有所有alertdialogs顯示時,我只點擊一個標記。 – androniennn