모든 마커에 테이핑 할 때 표시 할 텍스트가 포함 된 SQLite 데이터베이스에 설명 열이 있습니다. 모든 마커에는 고유 한 설명이 있습니다. 문제는 하나의 마커를 탭하면 다른 모든 AlertDialog
이 표시됩니다.맵 마커를 누르면 AlertDialog의 모든 다른 마커가 표시됩니다.
@Override
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.moveToFirst();
while (cur.isAfterLast() == false) {
String description = cur.getString(cur.getColumnIndexOrThrow("description"));
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.moveToNext();
}
cur.close();
db.close();
return true;
}
onTap
기능이 작동하는 것 같군 : 나는 다음과 같은 코드를 사용하고
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);
String description = cur.getString(cur.getColumnIndexOrThrow("description"));
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;
}
내가 모든 AlertDialog
에 인덱스를 할당한다는 것을 알고 있지만 나도 몰라 그것을하는 방법. 이 문제를 해결하려고했지만 그것을 할 수없는 것 같습니다. 문제를 해결하는 방법에 대한 제안?
정확히. 그래서'cur.moveToFirst()'를'cur.moveToPosition (index)'로 바꾸고'cur.moveToNext()'를 삭제해야한다는 뜻인가요? 그리고 왜 추천하지 않습니까? – androniennn
데이터를보기에 바인딩 할 때 한 번만로드해야하므로 바람직하지 않습니다. 댓글을다는 것이 어렵도록이 코드를 게시하지 않았습니다. 로컬 컬렉션에로드해야합니다. 그런 다음 사용자가 항목을 탭하면 색인으로 올바른 항목에 액세스하기 만하면됩니다. – ShibbyUK
'cur.moveToPosition (index)'을 시도했는데 응용 프로그램이 멈추고 강제 종료됩니다. – androniennn