0

I have a dialog where I use setSingleChoiceItems. When choosing the item "years" my dialog needs to make CheckBox visible. How can I do this?

This is my code:

                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // TODO 1) Удалить test_dialog.xml
                builder.setTitle(R.string.statistic_dialog_title)
                        .setSingleChoiceItems(R.array.statistic_chart_filter, 0, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                if (i == 0){
                                    Toast.makeText(getContext(), R.string.chart_filter_item_year, Toast.LENGTH_SHORT).show();
                                } if (i == 1){
                                    Toast.makeText(getContext(), R.string.chart_filter_item_month, Toast.LENGTH_SHORT).show();
                                }
                            }
                        })
                        .setView(inflater.inflate(R.layout.test_dialog, null))
                        .setPositiveButton(R.string.statistic_dialog_positive_button, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {

                            }
                        })
                        .setNegativeButton(R.string.statistic_dialog_negative_button, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {

                            }
                        });
                builder.show();

Thank you.

Chachmu
  • 7,725
  • 6
  • 30
  • 35
  • Why dont you make the checkbox invisible before then visible after clicking. – Steve Kamau Sep 05 '16 at 10:56
  • @SteveKamau In this case. How do I make my custom checkbox-list gone, when I check the condition of pressing? – Денис Климков Sep 05 '16 at 12:20
  • 1
    What exactlty do you want to toggle visibility? Is it the checkbox or the checklist? If it's the checklist then i suggest you create a custom dialog with a custom layout, add a listview with checkboxes there and other elements that you want. Then toggle the visibility onItemClick. This could get you started http://stackoverflow.com/questions/13341560/how-to-create-a-custom-dialog-box-in-android – Steve Kamau Sep 05 '16 at 12:28

0 Answers0