Source:
public void openDialog() { spinnerArrayAutoDown_keepUpdated = new ArrayList<>(); spinnerArrayAutoDelete = new ArrayList<>(); spinnerArrayAutoDown_keepUpdated.add(STRING_ENABLE); spinnerArrayAutoDown_keepUpdated.add(STRING_DISABLE); spinnerArrayAutoDown_keepUpdated.add(STRING_NO_FILTER); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArrayAutoDown_keepUpdated); spinnerAutoDownload.setAdapter(spinnerArrayAdapter); spinnerKeepUpdated.setAdapter(spinnerArrayAdapter); spinnerArrayAutoDelete.add(STRING_ALWAYS); spinnerArrayAutoDelete.add(STRING_NEVER); spinnerArrayAutoDelete.add(STRING_GLOBAL_DEFAULT); spinnerArrayAutoDelete.add(STRING_NO_FILTER); ArrayAdapter<String> spinnerArrayAdapter1 = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArrayAutoDelete); spinnerAutoDelete.setAdapter(spinnerArrayAdapter1); spinnerAutoDownload.setSelection(spinnerArrayAutoDown_keepUpdated.indexOf(autoDownload)); spinnerKeepUpdated.setSelection(spinnerArrayAutoDown_keepUpdated.indexOf(keepUpdated)); spinnerAutoDelete.setSelection(spinnerArrayAutoDelete.indexOf(autoDelete)); dialog.setTitle(R.string.filter); buttonCancel.setOnClickListener(v -> { dialog.cancel(); }); buttonConfirm.setOnClickListener(v -> { String autoDownloadValue = spinnerAutoDownload.getSelectedItem().toString(); String keepUpdatedValue = spinnerKeepUpdated.getSelectedItem().toString(); String autoDeleteValue = spinnerAutoDelete.getSelectedItem().toString(); final ArrayList<SubscriptionFilter> filterValues = new ArrayList<>(); filterValues.add(new SubscriptionFilter(STRING_AUTO_DOWNLOAD,autoDownloadValue)); filterValues.add(new SubscriptionFilter(STRING_KEEP_UPDATED,keepUpdatedValue)); filterValues.add(new SubscriptionFilter(STRING_AUTO_DELETE,autoDeleteValue)); updateFilter(filterValues); dialog.cancel(); }); dialog.show(); }

Target:
public AlertDialog openDialog() { View content = View.inflate(context, R.layout.dialog_layout, null); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setView(content); spinnerAutoDownload = content.findViewById(R.id.spinnerAutoDownload); spinnerKeepUpdated = content.findViewById(R.id.spinnerKeepUpdated); spinnerAutoDelete = content.findViewById(R.id.spinnerAutoDelete); ArrayList<String> spinnerArrayAutoDown_keepUpdated = new ArrayList<>(); ArrayList<String> spinnerArrayAutoDelete = new ArrayList<>(); spinnerArrayAutoDown_keepUpdated.add(STRING_ENABLE); spinnerArrayAutoDown_keepUpdated.add(STRING_DISABLE); spinnerArrayAutoDown_keepUpdated.add(STRING_NO_FILTER); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArrayAutoDown_keepUpdated); spinnerAutoDownload.setAdapter(spinnerArrayAdapter); spinnerKeepUpdated.setAdapter(spinnerArrayAdapter); spinnerArrayAutoDelete.add(STRING_ALWAYS); spinnerArrayAutoDelete.add(STRING_NEVER); spinnerArrayAutoDelete.add(STRING_GLOBAL_DEFAULT); spinnerArrayAutoDelete.add(STRING_NO_FILTER); ArrayAdapter<String> spinnerArrayAdapter1 = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArrayAutoDelete); spinnerAutoDelete.setAdapter(spinnerArrayAdapter1); spinnerAutoDownload.setSelection(spinnerArrayAutoDown_keepUpdated.indexOf(autoDownload.toString())); spinnerKeepUpdated.setSelection(spinnerArrayAutoDown_keepUpdated.indexOf(keepUpdated.toString())); spinnerAutoDelete.setSelection(spinnerArrayAutoDelete.indexOf(autoDelete.toString())); builder.setNegativeButton(R.string.cancel_label, (dialog, which) -> dialog.dismiss()); builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { updateFilter(SubscriptionFilter.AutoDownload.parse(spinnerAutoDownload.getSelectedItem().toString()), SubscriptionFilter.KeepUpdated.parse(spinnerKeepUpdated.getSelectedItem().toString()), SubscriptionFilter.AutoDelete.parse(spinnerAutoDelete.getSelectedItem().toString())); dialog.dismiss(); }); dialog = builder.create(); return dialog; }