Closed khalid-mahmood closed 7 years ago
I have Create BoostrapGroupButton and set type to "radio" when i click to any button its checked but when i click same button again its unchecked while radio button behavior is once checked it can't unchecked. one would be always selected from group... i have already checked first button.
@jamie-beardedhen any help ?
@khalid-mahmood please include a minimal code example so that someone can verify this
<LinearLayout android:id="@+id/tabs_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<com.beardedhen.androidbootstrap.BootstrapButtonGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
app:bootstrapBrand="custom"
app:bootstrapSize="xs"
app:buttonMode="radio"
app:roundedCorners="true"
app:showOutline="true">
<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/about_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="About School"
app:checked="true" />
<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/chairperson_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Chairperson Message" />
<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/gallery_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Gallery" />
</com.beardedhen.androidbootstrap.BootstrapButtonGroup>
</LinearLayout>
this is xml
btton.setOnCheckedChangedListener(new BootstrapButton.OnCheckedChangedListener() { @Override public void OnCheckedChanged(BootstrapButton bootstrapButton, boolean isChecked) { if (isChecked) { ..... } } });
initial then after click again on "about school" button
while it should be selected beacuse its a radio not toggle
Hope so you better understand now. @jamie-beardedhen
@jamie-beardedhen Waiting for answer. help please
Fixed in 2.3.1
@jamie-beardedhen
if button is previously checked and click again its return true again although it should return true only first if not checked.
i don't want to trigger action again on same button if its is already checked. any sugguestion ?
Change BootstrapButton Class
@Override
public void setSelected(boolean selected) {
if (onCheckedChangedListener != null) {
onCheckedChangedListener.OnCheckedChanged(this, selected);
}
super.setSelected(selected);
}
and use if (!bootstrapButton.isSelected() && isChecked) { .... } did the trick for me.
BoostrapGroupButton BootstrapButton type "radio" acting as toggle button. Radio button behaviour one should always checked !! how it is possible ? Thanks