안드로이드 개발 질문/답변
(글 수 45,052)
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
BusOpenHelper h = new BusOpenHelper(getApplicationContext());
try{
mDb=h.getWritableDatabase();
}catch (SQLException e){
mDb=h.getReadableDatabase();
}
Cursor c = fetchAllData(); /DB 쿼리로 데이터 받아오기
startManagingCursor(c);
String[] from=new String[] {BaseColumns._ID,"station"};
int[] to = new int[]{R.id._id,R.id.url};
mAdapter=new SimpleCursorAdapter(this,R.layout.dbresult,c,from,to);
setListAdapter(mAdapter);
}
이와 같이 되어 있고
아래와 같이 2개의 텍스트뷰로 구성된 커스텀 리스트입니다
이때 리스트아이템 클릭시 선택한 한쪽의 텍스트뷰의 텍스트값만 받고 싶은데 어떻게 해야하나요?
// TODO Auto-generated method stub
super.onResume();
BusOpenHelper h = new BusOpenHelper(getApplicationContext());
try{
mDb=h.getWritableDatabase();
}catch (SQLException e){
mDb=h.getReadableDatabase();
}
Cursor c = fetchAllData(); /DB 쿼리로 데이터 받아오기
startManagingCursor(c);
String[] from=new String[] {BaseColumns._ID,"station"};
int[] to = new int[]{R.id._id,R.id.url};
mAdapter=new SimpleCursorAdapter(this,R.layout.dbresult,c,from,to);
setListAdapter(mAdapter);
}
이와 같이 되어 있고
아래와 같이 2개의 텍스트뷰로 구성된 커스텀 리스트입니다
이때 리스트아이템 클릭시 선택한 한쪽의 텍스트뷰의 텍스트값만 받고 싶은데 어떻게 해야하나요?
Cursor c= mAdapter.getCursor();
String s = c.getString(0);
하니 클릭한 아이템의 0번인덱스 값을 가져오네요