I seek how to custom a CheckBox in my MultiChoiceItems (i think the original on the phone is not good).
MultiChoiceItems is in a AlertDialog:
AlertDialog.Builder builder = new AlertDialog.builder(context);
builder.setTitle("string")
.setMultiChoiceItems(item,selected,new DialogInterface.OnMultichoiceClickListener(){
public void onClick(DialogInterface dialogInterface,int item, boolean b){
booleanArrayList.set(item,b);
}
});
builder.setPositiveButton("ok",new DialogInterface.OnClickListener(){
public void onClick(DialogueInterface dialog,int which){
//Mon code//
}
});
builder.setNegativeButton("retour",null)
.create()
.show();
This is working, i only have an issue with the skin of my checkbox and i search and not found solution,someone have ever do this?
Sorry for my English (I'm French ^^').
Thank you.
Edit//After search,I haven't find solution so i want to test with a setview; but i have an Exception with my code :
AlertDialog.Builder builder = new AlertDialog.builder(context);
builder.setTitle("string");
builder.setPositiveButton("ok",new DialogInterface.OnClickListener(){
public void onClick(DialogueInterface dialog,int which){
//Mon code//
}
});
builder.setNegativeButton("retour",null)
And after that I add this : (this code is now ok for exception if someone need)
final AlertDialog alert = builder.create();
LayoutInflater infl = alert.getLayoutInflater();
View dialog = infl.inflate(R.layout.mylistview,null);
alert.setView(dialog);
ListView lv=(ListView)dialog.findViewById(R.id.listviewcustom);
TextView tx; CheckBox cb;
LayoutInflater infl2 = alertDialog.getLayoutInflater();
vALlistview= new arrayList<View>(item.lenght);
vAAlistview= new ArrayAdaptater(context,R.id.listviewcustom);
for(ibcl=0;ibcl<item.lenght;ibcl++){
View v = (infl2.inflate(R.layout.miccheckcustom,null);
tx=(TextView)vALlistview.getChildAt(ibcl).findViewById(R.id.txtcustom);
cb=(CheckBox)vALlistview.getChildAt(ibcl).findViewById(R.id.cbcustom);
tx.setText(sAlTopicPoss.get(ibcl));
cb.setChecked(false);
vAAlistview.add(vALlistview.get(ibcl));
}
vAAlistview.notifitDataSetChanged();
alert.show;
aspect of my xml (miccheckcustom):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout>
<TextView
android:id="txtcustom"/>
<CheckBox
android:id="cbcustom"/>
</LinearLayout>
But i have a LogCat tell me that : "w/Bundle: Attempt to cast generated internal exception java.lang.ClassCastException"
//Edit2 : for the exception , my code is correct now , you can't add in a list an item directly , only with an arrayadaptater?//
//Edit2 : But now , my listview do nothing , i am only with a windows which have a title , 2 button but no listview in see ... I continue to search ...//
Sorry for my precision , my code is on an other pc ^^'
The first question is always in actuallity (just for knowledge) but if someone can help me for the exception, thank a lot ;)