第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用兩組 RadioButtons 在 EditText 中輸入文本

如何使用兩組 RadioButtons 在 EditText 中輸入文本

嗶嗶one 2023-06-14 16:18:40
我有 2 組單選按鈕。我想在btn1stDigitBrown1按下第一組時(shí)在顯示屏上顯示“1”,就像下面的代碼一樣,當(dāng)btn2ndDigitBlack0按下第二組時(shí),它還應(yīng)該在剛剛寫的數(shù)字旁邊顯示一個(gè)數(shù)字EditText,例如,“10”。當(dāng)?shù)诙M的按鈕被按下時(shí)(例如btn2ndDigitBlack0)在第一組的按鈕被按下之前,它應(yīng)該自動(dòng)顯示在EditText“10”上?,F(xiàn)在,當(dāng)RadioButton按下第二組時(shí),它會(huì)重寫已經(jīng)寫在EditText. 這是我的代碼:    View.OnClickListener listener1stDigit = new View.OnClickListener() {        @Override        public void onClick(View view) {            switch (view.getId()) {                case R.id.btn1stDigitBrown1:                    ((EditText)findViewById(R.id.resistText)).setText("1");                    break;                case R.id.btn1stDigitRed2:                    ((EditText)findViewById(R.id.resistText)).setText("2");                    break;                case R.id.btn1stDigitOrange3:                    ((EditText)findViewById(R.id.resistText)).setText("3");                    break;                case R.id.btn1stDigitYellow4:                    ((EditText)findViewById(R.id.resistText)).setText("4");                    break;                case R.id.btn1stDigitGreen5:                    ((EditText)findViewById(R.id.resistText)).setText("5");                    break;                case R.id.btn1stDigitBlue6:                    ((EditText)findViewById(R.id.resistText)).setText("6");                    break;                case R.id.btn1stDigitViolet7:                    ((EditText)findViewById(R.id.resistText)).setText("7");                    break;                case R.id.btn1stDigitGrey8:                    ((EditText)findViewById(R.id.resistText)).setText("8");                    break;                case R.id.btn1stDigitWhite9:                    ((EditText)findViewById(R.id.resistText)).setText("9");                    break;                default:            }        }
查看完整描述

2 回答

?
達(dá)令說(shuō)

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")

? ? ? ? ?}

? ? ? ? ?}

? ? ?...


查看完整回答
反對(duì) 回復(fù) 2023-06-14
?
PIPIONE

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

...


查看完整回答
反對(duì) 回復(fù) 2023-06-14
  • 2 回答
  • 0 關(guān)注
  • 190 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)