有沒有一種簡單的方法來制作這個?我有大約 16 個這樣的復選框。
kartBox1.setOnClickListener{
if(kartBox1.isChecked){kartBox1.setBackgroundResource(R.drawable.check_button_checked)}
else{kartBox1.setBackgroundResource(R.drawable.check_button_unchecked)}}
kartBox2.setOnClickListener{
if(kartBox2.isChecked){kartBox2.setBackgroundResource(R.drawable.check_button_checked)}
else{kartBox2.setBackgroundResource(R.drawable.check_button_unchecked)}}
uj5u.com熱心網友回復:
您基本上可以創建這些按鈕的串列并使用 foreach 回圈并添加具有所有需要檢查的偵聽器。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/429814.html
