Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:58:59+00:00 2026-06-05T19:58:59+00:00

This is my static inner class for creating an AlertDialog inside my MainActivity class:

  • 0

This is my static inner class for creating an AlertDialog inside my MainActivity class:

public static class AboutDialogFragment extends DialogFragment {

    public static AboutDialogFragment newInstance() {
        AboutDialogFragment frag = new AboutDialogFragment();
        return frag;
    }  

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        return new AlertDialog.Builder(getActivity())
                .setIcon(R.drawable.ic_dialog_about)
                .setTitle(R.string.about)
                .setMessage(R.string.about_message)
                ..........
                .create();
    }
}

And I’m showing it when you press a menu item which is inside MainActivity:

case R.id.about:
        DialogFragment aboutFragment = AboutDialogFragment.newInstance();
        aboutFragment.show(getSupportFragmentManager(), "about_dialog");
        // Make links clickable
        ((TextView) aboutFragment.getDialog().findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
        return true;

I’m trying to make the links in the message text clickable using the commented line.

I found this method here and it has worked for me when using a regular Dialog (no fragments).
However, this is the first time I have tried using it on a DialogFragment and I always get a NullPointerException when trying to find the view.

I’ve also tried aboutFragment.getView().findViewById(android.R.id.message) but that returns null as well.

Maybe I am calling the code too early/in the wrong place?
Any ideas would be great!

EDIT: Just tried ((TextView) v.getRootView().findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
and
((TextView) v.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); in onCreateView() and also tried in onCreateDialog() without success.
Still getting null pointer exception…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:59:00+00:00Added an answer on June 5, 2026 at 7:59 pm

    Hopefully you’ve already figured this out but I just did this same thing and wanted to document it somewhere. Put this in your DialogFragment class:

    @Override
    public void onStart() {
        super.onStart();
        ((TextView) getDialog().findViewById(android.R.id.message))
                .setMovementMethod(LinkMovementMethod.getInstance());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a non-static inner class like this: class Sample { public void sam()
How to allow static initializer on a inner class like this: public class MyClass
How do I avoid requiring code like this: public static class BusinessLogicAutomapper { public
I am befuddled why this is allowed public class Foo { class Bar extends
If I have an inner class, like this: public class Test { public class
I have a class GridPanel extends JPanel , with a static inner class ToolSelectComboBox
I have inner class as broadcast receiver: public class ManualBacklightReceiver extends BroadcastReceiver { public
I've never seen code like this: public static function getInstance() { if ( !
When I try to compile this: public static Rand searchCount (int[] x) { int
When i try to compile this: public static int compareCardhl (Card c1, Card c2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.