diff --git a/SJDialog/src/main/java/com/sjapps/library/customdialog/ListDialog.java b/SJDialog/src/main/java/com/sjapps/library/customdialog/ListDialog.java index a8c1d05..bcca009 100644 --- a/SJDialog/src/main/java/com/sjapps/library/customdialog/ListDialog.java +++ b/SJDialog/src/main/java/com/sjapps/library/customdialog/ListDialog.java @@ -26,10 +26,12 @@ public class ListDialog extends SJDialog{ RecyclerView listRV; boolean isSelectableList = false; boolean hideEmptyListTxt = false; + boolean waitForLayoutManager = false; private @DrawableRes int listItemBgRes = R.drawable.ripple_list; private @DrawableRes int listItemBgResSelected = R.drawable.ripple_list_selected; private int listItemTextColor = 1; + private RecyclerView.LayoutManager layoutManager = null; RecyclerView.Adapter adapter; ArrayList selectedItems = new ArrayList<>(); @@ -254,7 +256,11 @@ public ListDialog onButtonClick(DialogButtonEvents dialogButtonEvents) { @Override public ListDialog show() { - listRV.setLayoutManager(new LinearLayoutManager(context)); + if (layoutManager == null) + layoutManager = new LinearLayoutManager(context); + if (!waitForLayoutManager) + listRV.setLayoutManager(layoutManager); + listRV.setAdapter(adapter); if (adapter == null) checkListsSize(0); @@ -572,6 +578,11 @@ public ListDialog setAdapter(RecyclerView.Adapter adapter){ return this; } + public ListDialog setLayoutManager(RecyclerView.LayoutManager layoutManager) { + this.layoutManager = layoutManager; + return this; + } + /** * Get a list adapter * @return current class