0

ListView(チェックボックスから選択したビュー)から選択したアイテムを取得する方法は? の からいくつかの結果を得HandlerましたCursorAdapter

public class MyCursorAdapter extends CursorAdapter {

@SuppressWarnings("deprecation")
public MyCursorAdapter(Context context, Cursor c) {
    super(context, c);
    // TODO Auto-generated constructor stub
}

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    TextView item=(TextView)view.findViewById(R.id.item_tv);
    CheckBox cb=(CheckBox)view.findViewById(R.id.flag_cb);

    item.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(1))));

    Log.d("Bind View", "Flag="+cursor.getString(cursor.getColumnIndex(cursor.getColumnName(2))));

    if(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(1))).equalsIgnoreCase("true")){
        cb.setChecked(true);
    }else{
        cb.setChecked(false);
    }

    cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            DatabaseHelperSQL help=new DatabaseHelperSQL(context);
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(isChecked){
                Toast.makeText(context, "Check", Toast.LENGTH_LONG).show();
            }else{
                Toast.makeText(context, "unCheck", Toast.LENGTH_LONG).show();
            }
        }   

    });

}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    LayoutInflater inflater=LayoutInflater.from(parent.getContext());
    View retView=inflater.inflate(R.layout.every_row,parent,false);
    return retView;
}

}
4

1 に答える 1