我想当我单击显示警报对话框的按钮“mButtonadd”时,我想在警报对话框上获得“mTextViewResult”的值(这是一个简单的乘法)
private EditText mEditText1;
private TextView mTextViewResult;
private Button mButtonAdd;
int a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_builderdaily);
mEditText1 = findViewById(R.id.editText1);
a = 15;
mTextViewResult = findViewById(R.id.textView);
mButtonAdd = findViewById(R.id.button);
mButtonAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mEditText1.getText().toString().length() == 0) {
mEditText1.setText("0");
}
int num1 = Integer.parseInt(mEditText1.getText().toString());
final int sum = num1 * a;
mTextViewResult.setText(String.valueOf(sum));
}
});
mButtonAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
AlertDialog alertDialog = new AlertDialog.Builder(BCdaily.this).create(); //Read Update
alertDialog.setTitle("hi");
alertDialog.setButton("Continue..", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
}
});
alertDialog.show(); //<-- See This!
}
});
}
}
我尝试编写此代码(alertDialog.setMessage(mTextViewResult.setText(String.valueOf(sum));)但没有成功。
qq_花开花谢_0
绝地无双
相关分类