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 8924641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:28:25+00:00 2026-06-15T07:28:25+00:00

I am trying to show a FragmentDialog ( created and shown as a dialog

  • 0

I am trying to show a FragmentDialog ( created and shown as a dialog NOT added as content in a view hierarchy) where there is a ViewPager whose content is given by a FragmentPagerAdapter (provides Fragments consisting of an image).

The code works perfect when showing ViewPager + FragmentPagerAdapter from a FragmentActivity, but get the following exception when doing it from a FragmentDialog:

“IllegalArgumentException: No view found for id 0x7f040077 for fragment SimpleFragment…”

Here is my code:

A SherlockFragmentActivity with a button to create and show the dialog.

public class BorrameActivity extends SherlockFragmentActivity{
    @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.one_act);

    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View arg0) {
            showTheDialog();

        }});
   }

   private void showTheDialog(){
       AchGalleryDialog newFragment = AchGalleryDialog.newInstance(achs);
       newFragment.show(getSupportFragmentManager(), "dialog");
   }

The FragmentDialog:

public class AchGalleryDialog extends DialogFragment{
    public AchGalleryDialog(){  
}

    public static AchGalleryDialog newInstance(){       
        AchGalleryDialog f = new AchGalleryDialog();
        return f;       
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.dialog_user_result, container);
        getDialog().setTitle("Hola tronco");

        //content to show in the fragments
        int[] images = new int[]{R.drawable.d1, R.drawable.d2, R.drawable.d3};

        ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
        MyFragmentAdapter adapter = new MyFragmentAdapter(getFragmentManager(),images);  
        pager.setAdapter(adapter);

        return view;
    }
}

This is the very simple MyFragmentPagerAdapter,
I put only the getItem() method, and nullPointer checks:

@Override
public Fragment getItem(int position) {
    return MySimpleFragment.newInstance(images[position]); 

}

And finally SimpleFragment:

public class SimpleFragment extends Fragment{
    int id;
    public static SimpleAchFragment newInstance(int imgId){
        SimpleFragment f = new SimpleFragment();
        Bundle args = new Bundle();
        args.putLong(ID_BUNDLE, imgId);
        f.setArguments(args);

        return f;
    }

    public SimpleAchFragment(){
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.id = getArguments() != null ? getArguments().getInt(ID_BUNDLE) : 0;    
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Inflate the layout for this fragment
        View v =  inflater.inflate(R.layout.simple_fragment, container, false);
        FragmentActivity mAct = getActivity();

        ImageView img = (ImageView) v.findViewById(R.id.image);
        img.setImageDrawable(mAct.getResources().getDrawable(id));

        return v;
    }

}

More info, if the content passed to the adapter ( an int array with 3 ints) has length zero, then the adapter doesn’t try to create any Fragment so dialogs appears correctly but empty (as expected).
The Exception is thrown at SimpleFragment.onCreateView() at the time of inflating.
The id referenced in the exception (as not found) correspond to ViewPager ‘s id, with is properly defined in R.layout.simple_fragment.

I have try also to build the Dialog with an AlertDialog.builder and also directly with Dialog() contructor, but get the same behaviour.

  • 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-15T07:28:26+00:00Added an answer on June 15, 2026 at 7:28 am

    Try this:

    In class AchGalleryDialog

    MyFragmentAdapter adapter = new MyFragmentAdapter(getChildFragmentManager(),images);
    

    instead of

    MyFragmentAdapter adapter = new MyFragmentAdapter(getFragmentManager(),images); 
    

    Because of this:

    http://developer.android.com/about/versions/android-4.2.html#NestedFragments

    Hope this will help!

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

Sidebar

Related Questions

Am trying to show a popup dialog or custom view on clicking of the
I'm trying to show defferent content for logged in and not users on one
I am trying to show a modal view controller that hovers over another viewcontroller.
I'm trying to show the count of a duplicate within a given column. I
I'm trying to show an image on a Report created with CR for VS2010.
I am trying to show the 8 most recent scans added by doing this:
I'm trying to show a jquery dialog box with code like: var message =
In my code, I'm trying to show Fragment in some case of FragmentDialog, but
I am trying to show a activity or a dialog when the phone is
I am trying to show the loop data in Lineedit but it is not

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.