I'm using databse in my app. I can create some "notes" , and define the type : Homework or Test.
Then I display it in a ListView. But, when the row is created, I'd like to check if I chose "Homework" as the type, and if I did, I add a checkbox to that row in my listView, but If I chose "Test", I do not display the CheckBox.
Then, with the checkbox I can set the homework as DONE or NOT DONE with the cb.isChecked(). But first I have to only display the checkBox if it's a homework. But I don't know how to check it..
How can I do that ?
Here's my CustomAdapter class
public class CustomAdapterJalons extends SimpleCursorAdapter {
private Context mContext;
private Context appContext;
private int layout;
private Cursor cr;
private final LayoutInflater inflater;
public CustomAdapterJalons(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
this.layout = layout;
this.mContext = context;
this.inflater = LayoutInflater.from(context);
this.cr = c;
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(layout, null);
}
@Override
public void bindView(View view, final Context context, final Cursor cursor) {
super.bindView(view, context, cursor);
LinearLayout root_view = (LinearLayout)view.findViewById(R.id.item_root);
root_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//method
}
});
CheckBox cbdevoir = (CheckBox)view.findViewById(R.id.CBDevoir);
if(cbdevoir.isChecked())
{
//method to set the homework done
}
else
{
//method to set the homework undone
}
}
}
Thank you guys !
Aucun commentaire:
Enregistrer un commentaire