2 回答

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
我認(rèn)為你需要做的是學(xué)習(xí)如何操作字符串?
你應(yīng)該在第二個(gè)聽(tīng)眾中做的是連接新號(hào)碼
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貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超9個(gè)贊
setText(...) 重寫 TextView 中的文本。要在末尾添加文本,請(qǐng)使用 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
...
添加回答
舉報(bào)