make single-choice mode work in KeyChoiceAdapter
This commit is contained in:
@@ -82,6 +82,8 @@ public class KeyChoiceAdapter extends FlexibleAdapter<KeyChoiceItem> {
|
|||||||
throw new IllegalStateException("Cannot get active item in single select mode!");
|
throw new IllegalStateException("Cannot get active item in single select mode!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
Integer prevActiveItem = this.activeItem;
|
Integer prevActiveItem = this.activeItem;
|
||||||
this.activeItem = newActiveItem;
|
this.activeItem = newActiveItem;
|
||||||
|
|
||||||
@@ -89,6 +91,7 @@ public class KeyChoiceAdapter extends FlexibleAdapter<KeyChoiceItem> {
|
|||||||
notifyItemChanged(prevActiveItem);
|
notifyItemChanged(prevActiveItem);
|
||||||
}
|
}
|
||||||
if (newActiveItem != null) {
|
if (newActiveItem != null) {
|
||||||
|
toggleSelection(newActiveItem);
|
||||||
notifyItemChanged(newActiveItem);
|
notifyItemChanged(newActiveItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Select"
|
android:text="Select"
|
||||||
android:id="@+id/button_select"
|
android:id="@+id/button_select"
|
||||||
android:enabled="false"
|
|
||||||
style="?buttonBarButtonStyle" />
|
style="?buttonBarButtonStyle" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -116,7 +116,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Select"
|
android:text="Select"
|
||||||
android:id="@+id/button_select"
|
android:id="@+id/button_select"
|
||||||
android:enabled="false"
|
|
||||||
style="?buttonBarButtonStyle" />
|
style="?buttonBarButtonStyle" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user