@Override
protected Dialog onCreateDialog (int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.instant_alert_screen_title);
builder.setInverseBackgroundForced(true);
ListView aa = new ListView(this);
aa.setAdapter( new IconicAdapter());
aa.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
switch (arg2) {
case 0:
......
break;
case 1:
......
break;
case 2:
......
break;
builder.setView(aa);
builder.setPositiveButton("Done", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.setNegativeButton("Cancel", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
return builder.create();
Ok guys..I have a AlertDialog..In Adapter i set to dialog 3 CheckedTextView…
How in on Positive Button Listener i could find a second item and check is it checked or not ?
Dont recomend me to do like this:
CheckedTextView a = (CheckedTextView)findViewById(R.id.text)
boolean b = a.isChecked();
I need to use onClick(DialogInterface dialog, int which) this dialog Interface…is that real ?
Doyou mean find a second item in the dialog? When you add it to the dialog, save a reference to it and use that reference in your listener. (If it’s a local variable, you’ll need to declare it
finalto use it in the OnClickListener inner class.) Also, the code you don’t want us to recommend might work if you changed it to