material-dialogs with edit text and multi choice

10.7k Views Asked by At

I am using afollestad/material-dialogs to create dialog with edit text and positive and negative buttons. What I want to achieve is adding multi choice input so the user can select an item from a list of items. my code so far looks like that:

 private void buildAlertDialog() {
    final String[] str = {""};
    MaterialDialog builder = new MaterialDialog.Builder(this)
            .title("Add Item")
            .widgetColor(getResources().getColor(R.color.ColorPrimaryDark))
            .inputMaxLength(30,R.color.material_blue_grey_950)
            .inputType(InputType.TYPE_CLASS_TEXT)
            .input("add shopping item", "", new MaterialDialog.InputCallback() {
                @Override
                public void onInput(MaterialDialog dialog, CharSequence input) {
                    str[0] = input.toString();
                    //add it to shoppingListItems and save to sharedPreferences
                    shoppingListItems.add(str[0]);
                    saveShoppingItems();
                    isListEmpty();
                }
            }).negativeText("Cancel").show();
}

I tried to add neutral button ("add quantity") and when its pressed it displays another dialog, which was Multilist dialog. The problem was that when I press the positive button on this dialog the previous one (the one on the picture) hidden as well. I don't want that. Does anybody as an idea of how can I achieve a dialog with input edit text (for the shopping item) and a multi list choices ? (preferably in one dialog) What I have now looks like that: enter image description here

0

There are 0 best solutions below