내 활동 코드는 데이터베이스listview에서 클릭 한 항목의 위치를 얻는 방법은 무엇입니까? 상태를 업데이트 ListActivity에서 항목의 위치를 얻을 수
당신은 당신의 ListView에 setOnItemClickListener를 호출 할 필요가public class ViewList extends ListActivity {
private ListViewAdapter lAdapter;
DBAdapter db;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
db = new DBAdapter(this);
db.open();
Cursor cursor = db.fetchAllDeliveryItem();
lAdapter = new ListViewAdapter(getApplicationContext(),cursor);
//Toast.makeText(getApplicationContext(), cursor.getString(1), Toast.LENGTH_SHORT).show();
setListAdapter(lAdapter);
}
private class ListViewAdapter extends CursorAdapter{
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return super.getView(position, convertView, parent);
}
public ListViewAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView tvListText = (TextView)view.findViewById(R.id.label);
CheckBox cbListCheck = (CheckBox)view.findViewById(R.id.check);
tvListText.setText(cursor.getString(cursor.getColumnIndex("itemname")));
**cbListCheck.setChecked((cursor.getInt(cursor.getColumnIndex("delivered"))==0? false:true));
cbListCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
db.updateItem(position);**
}
});
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return li.inflate(R.layout.receiverow, parent, false);
}
하지만 내 레이아웃 목록보기가 없습니다 –
다음 단순히 구현 : onListI ListActivity에서 temClick (ListView l, View v, int 위치, long id). 그것의 매우 명확한 문서 : http : //developer.android.com/reference/android/app/ListActivity.html – slayton
나는 int 위치를 만듭니다; on.Item = position onListItemClick 메서드를 할당하지만 클릭 한 모든 항목을 0으로 반환합니다. ( –