중복 된 질문으로 불릴 수도 있지만 내 사례가 매우 독특하다는 것을 알고 있습니다. 기본적으로 내 커서 ID를 얻는 방법이 필요합니다. 즉, 사용자 지정 어댑터로 구문 분석 된 테이블의 데이터베이스에서 가져온 ID입니다. 그래서 내가 그 목록을 클릭하면, 그것은 정확한 id를 토스트한다. 여기에 내가 지금까지 가지고있는 무엇입니까 ...커서에서 CustomAdapter로 데이터베이스 ID 가져 오기 (Android)
나는 cursoradapter가 아니라 customadapter를 사용하고 싶습니다.
//Get Categories from database
final Cursor cursor = dbHandler.getCategories(0);
if (cursor != null) {
if(cursor.moveToFirst()){
do{
Categories categories = new Categories();
categories.set_id(cursor.getInt(0));
categories.set_categoryname(cursor.getString(2));
categories.set_categoriescaption(cursor.getString(3));
//list.add(cursor.getString(cursor.getColumnIndex(dbHandler.COLUMN_CATEGORY_NAME)));
categoriesList.add(categories);
}while (cursor.moveToNext());
}
cursor.close();
}
커서 내가 버튼 및 아니오받은 위치 ID를 클릭하면 테이블의 실제 ID가 보여 싶은 내 SQLite 데이터베이스
listView = (ListView) view.findViewById(R.id.categories);
adapter = new CategoryAdapter(view.getContext(), R.layout.cursor_row, categoriesList);
listView.setAdapter(adapter);
listView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String cid = String.valueOf(id);
Toast.makeText(view.getContext(), cid , Toast.LENGTH_SHORT).show();
에서 데이터를 얻을. 진짜 이드는 1부터 시작해야하는데, 여기서 0을 얻고 있습니다. 도움을 받으실 수 있습니다. 고마워요