my problem is put fragment component on two fragments in the same layout. It is a dialog fragment which covers the window with menu(1 fragment) and table(2 fragment). How can I do that ?
You could use relative layout to put fragment on the top of other fragments in the same layout.
http://developer.android.com/guide/topics/ui/layout/relative.html
Related
I have a parent fragment containing TabLayout and ViewPager.
The TabLayout has 3 tabs (fragments) managed by FragmentStatePagerAdapter.
After the user clicks on a button on the 3 fragment, I would like to replace it with different fragment, without reloading the parent fragment.
I tried to remove the fragment and add the new one and call notifyDataSetChanged() and the fragment is indeed replaced, but the TabLayout custom view headers are gone...
Any idea how can I do it right?
Thanks.
You can have the 3rd Fragment working as a holder for two child Fragments which you can switch based on your app's logic (clicking the button you mention).
The key for this alternative is that the 3rd Fragment in the ViewPager will be the parent of the two Fragments that will be switching.
The two child Fragments will communicate with the parent Fragment for the parent to take care of doing the switching.
For the switching the parent will use a ChildFragmentManager instead of the FragmentManager used for Fragments that are managed by Activities.
Im working with fragments on my main activity I have a Edit Text and buttons in my main activity But when I opens fragment page and click exact at the spot of Edit Text the keyboard activates.
So it means the below activity is also in working at same time
Fragments are designed to be inside an activity, if you don't want to make your activity visible you can use a full screen layout for fragment, to remove the clicks you can replace .add command with .replace when transacting to fragments give a background color to the root view of fragment layout also. I think this would help
YourFragment fragment = new YourFragment();
getSupportFragmentManager().beginTransaction()
.replace(R.id.ll_job_view_fragment_container, fragment)
.addToBackStack(TAG_FRAGMENT_YOUR_VIEW)
.commit();
Edit
The replace may not help, If you inflate different fragments in the same container you just give the attribute android:clickable="true" to the top most parent view of each fragment that will help.
I have a FrameLayout container in which I use the replace method to put a fragment when an item is selected from the navigation drawer.
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getFragmentTag()).commit();
I have a fragment which has a ViewPager within it. I have 3 fragments which are displayed in a tab layout with the ViewPager. When I select another item from the navigation drawer the fragment with the ViewPager is replaced but the fragments within are not detached. The system calls only the fragment with the ViewPager onDetach/onDestroy etc. methods but not the methods of the fragments it contains.
I am using FragmentPagerAdapter and I tried with the FragmentStatePager adapter. Nothing changes. I am using the default setOffscreenPageLimit(1);
How can I get my ViewPager fragments methods onDetach/onDestroy called?
Thanks!
Are you using the FragmentManager or the child Fragment Manager? If you create a Fragment inside another Fragment and you want the inner Fragment to behave like the outer, you should get the child fragment manager from the outer fragment and use it to create the inner fragments. See this.
I am using FragmentTabHost to display the Tab inside the fragment. From parent fragment I am calling a child fragment inside the child fragment I want to hide the tab please any one help me on this
I'm using a frame layout to have more than one fragment in the same section of the screen.
So, I have a frame layout tag and then few fragment tags under it in XML.
So, I can see the overlap of these fragments.
I want to hide all the fragments except the one I want to show.
Where should I call the hide function?
If you are using support library for fragments use getSupportFragmentManager().beginTransaction().replace(<resource id for frame layout>, <new fragment>).commit()
This would replace all the fragments that are attached to this framelayout with the new fragment.