import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class Alertbox extends Activity {
/** Called when the activity is first created. */
AlertDialog.Builder builder;
AlertDialog alert;
EditText et;
Button b1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et=(EditText)findViewById(R.id.editText1);
b1=(Button)findViewById(R.id.button1);
builder=new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setMessage("dou you realy want to reset");
builder.setPositiveButton("yes",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
et.setText("");
}
});
builder.setNegativeButton("No",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
alert=builder.create();
b1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
alert.show();
}
});
}
}
No comments:
Post a Comment