Fragment being launched from FragmentActivity not showing up

A Nice Guy

I am using the following code to launch a new fragment from a FragmentActivity:

PlaceholderFragment placeholderFragment = new PlaceholderFragment();
String TAG="TestFragment";
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.fragment_container, newFrag, TAG);
ft.addToBackStack(TAG);
ft.commit();

The Placeholderfragment:

public class PlaceholderFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container,
                false);
        return rootView;
    }
}

For some reason, the "fragment_main" layout is not showing up.

I have debugged the flow and the etire code is executed but the screen stays at my FragmentActivity. Anyone has any idea why this might happen? I have already wasted an hour without any clue.

A Nice Guy

@Xaver Kapeller: You are right, it turned out the R.id.fragment_container was obscured by the parent linear_layout of the FragmentActivity as it had "fill_parent" specified.

Looks like my concepts of fragments are not very clear :P

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

FragmentActivity not showing the right layout for the fragment

From Dev

Call FragmentActivity from Fragment

From Dev

Fragment not launched from another fragment

From Dev

Textviews not showing up from array and fragment?

From Dev

refresh fragment UI from fragmentActivity

From Dev

Import text from fragmentactivity to fragment

From Dev

refresh fragment UI from fragmentActivity

From Dev

Open new Fragment from FragmentActivity

From Dev

Menu in not showing up in Fragment

From Dev

Toolbar not showing up in Fragment

From Dev

Activity not launched from inside fragment

From Dev

Browser Not Being Launched From Service

From Dev

Get id of TextView in Fragment from FragmentActivity in ViewPager

From Dev

Android - How to access a Fragment from a FragmentActivity

From Dev

(Android) how to call method in fragment from fragmentActivity

From Dev

Android - Back button from FragmentActivity to another Fragment

From Dev

Sending a string from FragmentActivity to Fragment through FragmentPagerAdaptor

From Dev

How to pass parameter to Fragment from FragmentActivity

From Dev

onActivityResult not being called inside FragmentActivity that contains Android Map view fragment

From Dev

ProgressDialog not showing up within a Fragment

From Dev

App is not being restored when launched from Home

From Dev

How to call fragment from activity without using fragmentactivity?

From Dev

How to call a fragment layout from the FragmentActivity to avoid NullPointerException

From Dev

Nullpointer Exception in FragmentActivity while showing data in Spinner from database

From Dev

fragment run before fragmentActivity

From Dev

Android problems with fragment and fragmentActivity

From Dev

Refresh Fragment in FragmentActivity

From Dev

Fragment transaction with a FragmentActivity instead of a Fragment

From Dev

toolbar not showing up in fragment with google maps

Related Related

  1. 1

    FragmentActivity not showing the right layout for the fragment

  2. 2

    Call FragmentActivity from Fragment

  3. 3

    Fragment not launched from another fragment

  4. 4

    Textviews not showing up from array and fragment?

  5. 5

    refresh fragment UI from fragmentActivity

  6. 6

    Import text from fragmentactivity to fragment

  7. 7

    refresh fragment UI from fragmentActivity

  8. 8

    Open new Fragment from FragmentActivity

  9. 9

    Menu in not showing up in Fragment

  10. 10

    Toolbar not showing up in Fragment

  11. 11

    Activity not launched from inside fragment

  12. 12

    Browser Not Being Launched From Service

  13. 13

    Get id of TextView in Fragment from FragmentActivity in ViewPager

  14. 14

    Android - How to access a Fragment from a FragmentActivity

  15. 15

    (Android) how to call method in fragment from fragmentActivity

  16. 16

    Android - Back button from FragmentActivity to another Fragment

  17. 17

    Sending a string from FragmentActivity to Fragment through FragmentPagerAdaptor

  18. 18

    How to pass parameter to Fragment from FragmentActivity

  19. 19

    onActivityResult not being called inside FragmentActivity that contains Android Map view fragment

  20. 20

    ProgressDialog not showing up within a Fragment

  21. 21

    App is not being restored when launched from Home

  22. 22

    How to call fragment from activity without using fragmentactivity?

  23. 23

    How to call a fragment layout from the FragmentActivity to avoid NullPointerException

  24. 24

    Nullpointer Exception in FragmentActivity while showing data in Spinner from database

  25. 25

    fragment run before fragmentActivity

  26. 26

    Android problems with fragment and fragmentActivity

  27. 27

    Refresh Fragment in FragmentActivity

  28. 28

    Fragment transaction with a FragmentActivity instead of a Fragment

  29. 29

    toolbar not showing up in fragment with google maps

HotTag

Archive