我有一个在PrepaidBase中声明的警告对话框,它有两个方法alertDialogShow()和call()。单击"是"时调用call()方法;警告对话框的按钮和alertDialogShow()方法调用激活布局的按钮。
PrepaidBase
public class PrepaidBase extends Activity {
private String number = "";
public void alertDialogShow(Context context, String title, String message, String _number) {
this.number = _number;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(message);
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
call();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
}
public void call()
{
Intent in = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(number)));
try
{
startActivity(in);
alertDialogShow(this, "Some Test", "Text Here too", "*1234#");
}catch (ActivityNotFoundException e)
{
e.printStackTrace();
}
}
现在这个类继承自PrepaidBase类
public class PrepaidLBO extends PrepaidBase {
Button chobeesButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chobeesghantay);
chobeesButton = (Button)findViewById(R.id.chobeesButton);
chobeesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//alertDialogShow(PrepaidLBO.this, "Some Test", "Text Here too", "*1234#");
call();
}
});
}
问题是
我想在点击chobeesButton时调用alertDialogMethod()。单击警告对话框的正按钮时调用Call()方法。