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

  • SEARCH
  • Home
  • 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 9193059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:04:18+00:00 2026-06-17T21:04:18+00:00

So I created a DialogFragment .java file to display my Alert Dialog. I used

  • 0

So I created a DialogFragment .java file to display my Alert Dialog. I used the tutorial here to create an AlertDialog with a list.

How can I reference this fragment in my ContactList.java file? What I understood to be the way to do this from the tutorial didn’t seem to work. When I’m trying to do the onClick event using the code below in my ContactList.java file, I get a red squiggly under getSupportFragmentManager().
Here’s the code I have for the fragment:

public class StatusDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.choose_status);
    builder.setItems(R.array.status_choices,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                }
            });
    return builder.create();
}

}

Here’s my relevant ContactList.java file code:

public class ContactList extends Activity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_contact_list);
    Intent intent = getIntent();


}
public void chooseStatus(View view) {
    DialogFragment newFragment = new StatusDialogFragment();
    newFragment.show(getSupportFragmentManager(), "statuschoice");
}

Lastly, here’s the XML code for my button that I want to open the dialog.

    <ImageButton
    android:id="@+id/status"  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/status_available_icon"
    android:onClick="chooseStatus" />

Thanks for your time.

  • 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-17T21:04:19+00:00Added an answer on June 17, 2026 at 9:04 pm

    You need to extend the compatibility class FragmentActivity if you’re coding for platforms below 3.0:

    public class ContactList extends FragmentActivity implements OnClickListener {
    

    If not, change getSupportFragmentManager() to getFragmentManager()

    Also make sure that if you’re using FragmentActivity, that your StatusDialogFragment extends the compatibility DialogFragment from the support package.

    And if not (meaning you’re only targeting 3.0+), make sure that the DialogFragment class you extend from is not from the support package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a DialogFragment and used getDialog().setTitle(Application failed to decrypt the file) and the
Created a AlertDialog that is used to prompting the user to enter a keyword.
I have created a custom dialog box extending the DialogFragment class. As stated in
I am trying to create a Custom dialog via DialogFragment. i want to have
I have a DialogFragment that creates a listview dialog and on a list item
I have created an DialogFragment which is building and returning AlertDialog from onCreateDialog method.
I have an inner class to create and show a simple list dialog. private
In the official example http://developer.android.com/reference/android/app/DialogFragment.html#BasicDialog the fragment is being created with use of static
I have a Fragment that can create and pop up a DialogFragment, but when
I have an AlertDialog implemented via DialogFragment.onCreateDialog() . The dialog has an EditText and

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.