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) {
}
});