Unable to use Dialog Widget
See original GitHub issueI have below code written in my fragment to use Dialog Widget, but it always throws NullPointerException
when I try to show dialog with dialog.show
Code within Fragment:
Dialog dialog = new Dialog(MyActivity.getLoginRegisterActivityInstance(), "Account locked!", result.getErrorMessage());
dialog.setCancelable(false);
dialog.setOnAcceptButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
ft.replace(R.id.logincontent, new RegisterFragment(), null);
ft.commit();
}
});
ButtonFlat acceptButton = dialog.getButtonAccept();
acceptButton.setText("Ok");
ButtonFlat cancelButton = dialog.getButtonCancel();
cancelButton.setVisibility(View.GONE);
dialog.show(); //Exception here
What could be the possible reason?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
showing a dialog doesn't work when the widget is the direct ...
1 Answer 1 ... This happens because you can only call showDialog(context) passing in a BuildContext that has an MaterialApp as an ancestor...
Read more >AlertDialog class - material library - Flutter - Dart API docs
Consider using a scrolling widget for content, such as SingleChildScrollView, to avoid overflow. (However, be aware that since AlertDialog tries to size ...
Read more >ARIA: dialog role - Accessibility - MDN Web Docs - Mozilla
The dialog role is used to mark up an HTML based application dialog or window that separates content or UI from the rest...
Read more >Displaying dialogs with DialogFragment - Android Developers
Just like with onCreateView() , you can return any subclass of Dialog from onCreateDialog() and are not limited to using only AlertDialog ....
Read more >Creating dialogs in Flutter - LogRocket Blog
Create alert dialogs, custom dialogs, and full-screen dialogs in Flutter for a better user experience in your mobile applications.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We are working now on an update, i note also this issue to be resolved in the next version
Thanks much for taking this into consideration…