Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

findViewById in Dialog with ContentView from a xml #456

Open
ghost opened this issue Jun 22, 2018 · 0 comments
Open

findViewById in Dialog with ContentView from a xml #456

ghost opened this issue Jun 22, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 22, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants