rey5137/material

findViewById in Dialog with ContentView from a xml

xamo1998 opened this issue · 0 comments

Hi, I have my dialog with a custom layout and I need to get the views for that layout when the Dialog is inflated. Here is my code:
final Dialog dialog = new Dialog(view.getContext()); dialog.positiveAction("Ok") .negativeAction("Cancel") .contentView(R.layout.chronometer_picker) .backgroundColor(attributes.getBackgroundColor()) .titleColor(attributes.getPrimaryTextColor()) .cancelable(true) .negativeActionClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Use a View from the layout... RadioButton button = view.findViewById(R.id.buttonId); dialog.cancel(); } }) .title("Choose the Chronometer") .show();
In this case findViewById throws a null pointer exception if I use the button so my question is how to instanciate my button even if the layout is not inflated.
My tought is to do it programmatically but is a complex layout.

Thanks.