import build.gradle
allprojects {note : Only one attribute for disabling or enabling unselecting mode Just specify flag in NestedRadioGroup
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Jamshid-M:NestedRadioGroup:1.1'
}
app:unselectable="true"Create layout
<uz.jamshid.libarary.NestedRadioGroupYou can handle SelectListener with lambda or in simple kotlin/java way
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp"
app:unselectable="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Voice"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_btn_speak_now"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Add"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_input_add"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Delete"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_delete"/>
</LinearLayout>
</uz.jamshid.libarary.NestedRadioGroup>
rg.setRadioGroupListener({NestedRadioGroup have 3 callbacks
Log.d("NestedRadioGroup", "select")
}, {
Log.d("NestedRadioGroup", "unSelect")
},{
Log.d("NestedRadioGroup", "reSelect")
})
onSelect
onUnSelect
onReSelect
You can also listen for only one callback, just by setting explicitly in lambda
rg.setRadioGroupListener(onUnSelect = {You can download at github
Log.d("NestedRadioGroup", "onUnSelect")
})
No comments:
Post a Comment