question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use Dialog Widget

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
xceldercommented, Nov 11, 2016

We are working now on an update, i note also this issue to be resolved in the next version

0reactions
kshkrao3commented, Nov 11, 2016

Thanks much for taking this into consideration…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found