From d59ad65ae850303b4b7c6cae7c7f5c447395eaf8 Mon Sep 17 00:00:00 2001 From: Ahmed Yusuf Date: Thu, 27 Feb 2020 20:38:18 +0700 Subject: [PATCH] update list checkbox --- .../paperplay/androidformbuilder/ExampleJavaActivity.java | 3 ++- .../paperplay/myformbuilder/view/MyMultipleCheckbox.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/paperplay/androidformbuilder/ExampleJavaActivity.java b/app/src/main/java/com/paperplay/androidformbuilder/ExampleJavaActivity.java index 372940d..f0f146d 100644 --- a/app/src/main/java/com/paperplay/androidformbuilder/ExampleJavaActivity.java +++ b/app/src/main/java/com/paperplay/androidformbuilder/ExampleJavaActivity.java @@ -57,7 +57,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { atcListChk.add(new CheckboxData(2, "1", "Satu Dua", false)); atcListChk.add(new CheckboxData(3, "3", "Tiga", false)); MyMultipleCheckbox myMultipleCheckbox = new MyMultipleCheckbox.Builder(ExampleJavaActivity.this) - .setTitle("Select Checkbox").setItem(atcListChk).setFormLayout(formLayout).create(); + .setTitle("Select Checkbox").setItem(new ArrayList<>()).setFormLayout(formLayout).create(); + myMultipleCheckbox.updateListCheckbox(atcListChk); ArrayList idSelected = new ArrayList<>(); idSelected.add("1"); idSelected.add("3"); diff --git a/myformbuilder/src/main/java/com/paperplay/myformbuilder/view/MyMultipleCheckbox.java b/myformbuilder/src/main/java/com/paperplay/myformbuilder/view/MyMultipleCheckbox.java index d1148a6..f887f29 100644 --- a/myformbuilder/src/main/java/com/paperplay/myformbuilder/view/MyMultipleCheckbox.java +++ b/myformbuilder/src/main/java/com/paperplay/myformbuilder/view/MyMultipleCheckbox.java @@ -242,6 +242,14 @@ public void setSelected(ArrayList dataList, SelectedBy selectedBy){ } } + public void updateListCheckbox(ArrayList list){ + this.list.clear(); + this.list.addAll(list); + if(adapter!=null){ + adapter.notifyDataSetChanged(); + } + } + public TextView getTxtTitle() { return txtTitle; }