lundi 5 septembre 2016

Android Dialog - Filter

I have dialog, where there I use setSingleChoiceItems. When choose item "years" my dialog need does visable ChackBox. How can I do it?

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.

Aucun commentaire:

Enregistrer un commentaire