hi,
Below is the code scratch.
After OK button is clicked, the dialog dismisses. But onClick function
does not be called.
Why?
Thanks.
********** HelloworldActivity.java
public class HelloworldActivity extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)findViewById(R.id.button1)).setOnClickListener(new
OnClickListener() {
public void onClick(View v)
{
DialogInterface.OnDismissListener mListener = new
DialogInterface.OnDismissListener(){
@Override
public void
onDismiss(DialogInterface dialog) {
Log.i("hello", "setOnDismissListener");
}};
ReadDateSetDialog.showDialog(HelloworldActivity.this, mListener);
}});
}
}
********** ReadDateSetDialog.java
public class ReadDateSetDialog{
private static Activity mAct;
static Dialog showDialog(final Activity activity,
DialogInterface.OnDismissListener listener) {
mAct = activity;
final AlertDialog.Builder builder = new
AlertDialog.Builder(mAct);
builder.setTitle("Test");
builder.setPositiveButton("Ok", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
whichButton) {
/* User clicked OK so do some stuff */
}
});
builder.setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
whichButton) {
/* User clicked cancel so do some stuff
*/
}
});
Dialog mDialog = builder.create();
if (listener != null) {
mDialog.setOnDismissListener(listener);
}
builder.show();
return mDialog;
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en