2 回答

TA貢獻1821條經驗 獲得超6個贊
我認為你需要做的是學習如何操作字符串?
你應該在第二個聽眾中做的是連接新號碼
switch (view.getId()) {
? ? ?case R.id.btn2ndDigitBlack0: {
? ? ? ? ?EditText editText = ((EditText)findViewById(R.id.resistText))
? ? ? ? ?String oldString = editText.getText()
? ? ? ? ?if (oldString.length <= 1) {
? ? ? ? ? ? editText.setText(oldString + "0")
? ? ? ? ?} else {
? ? ? ? ? ? ?editText.setText(oldString.substring(0, 1) + "0")
? ? ? ? ?}
? ? ? ? ?}
? ? ?...

TA貢獻1829條經驗 獲得超9個贊
setText(...) 重寫 TextView 中的文本。要在末尾添加文本,請使用 append(...)
例如:
TextView textView = findViewById<TextView>(R.id.some_text_view);
textView.setText("1"); //text contain 1
textView.setText("2"); //text contain 2
textView.setText("3"); //text contain 3
textView.append("1"); //text contain 31
textView.append("2"); //text contain 312
...
添加回答
舉報