xml代碼:
<RadioButton
android:id="@id/radio_button"
android:layout_width="165dp"
android:layout_height="30dp"
style="@style/CustomRadioBtn"
android:checked="true" />
CustomRadioBtn:
<style name="CustomRadioBtn">
<item name="android:gravity">center</item>
<item name="android:background">@drawable/radiobutton_background</item>
<item name="android:button">@null</item>
</style>
radiobutton_background:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- RadioButton 動態(tài)改變背景色 -->
<item android:drawable="@drawable/radiobutton_background_checked" android:state_checked="true" />
<!-- not selected -->
<item android:drawable="@drawable/radiobutton_background_unchecked" android:state_checked="false" />
</selector>
radiobutton_background_checked:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充 -->
<solid android:color="@color/black" />
<!-- 圓角 -->
<corners android:radius="5dp" />
</shape>
radiobutton_background_unchecked:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充 -->
<solid android:color="@color/grey" />
<!-- 圓角 -->
<corners android:radius="5dp" />
</shape>
EditText輸入狀態(tài)監(jiān)聽
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (TextUtils.isEmpty(editText.getText())){
//如果為空
nextButton.setEnabled(false);
}else {
nextButton.setEnabled(true);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。