b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (e1.getText().toString().isEmpty()||e2.getText().toString().isEmpty()) { Toast.makeText(MainActivity.this, "空", Toast.LENGTH_SHORT).show(); } else if (r1.isChecked()) { Double wb1 = Double.parseDouble(e1.getText().toString()); Double wb2 = Double.parseDouble(e2.getText().toString()); Double result = wb1 +wb2; t1.setText(result.toString()); } else if (r2.isChecked()) { Double wb1 = Double.parseDouble(e1.getText().toString()); Double wb2 = Double.parseDouble(e2.getText().toString()); Double result = wb1 - wb2; t1.setText(result.toString()); } else { AlertDialog.Builder dlg = new AlertDialog.Builder(MainActivity.this); dlg.setTitle("错误error"); dlg.setMessage("请检查控件或文本框有没有被输入和选中"); dlg.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dlg.show(); }
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦