android-nested-fragment

getChildFragmentManager() and viewpager

ぐ巨炮叔叔 提交于 2019-12-06 05:56:21
问题 I have the same problem as Navigating back to FragmentPagerAdapter -> fragments are empty but would like some clarification on the solution of using getChildFragmentManager(). This solution uses getChildFragmentManager(), the manager for fragments inside this Fragment(OuterFragment, which has the viewpager). InnerFragment is a page inside OuterFragment. When someone clicks the listview in InnerFragment, I want InnerFragment2 to replace InnerFragment. What do the xml and fragment managers look

ViewPager setOffscreenPageLimit not working when using it as NestedFragment with getChildFragmentManager

二次信任 提交于 2019-12-06 05:07:15
I am trying to do something similar as https://stackoverflow.com/a/24437224/2277631 . I am even using the same layout: I am following this approach because I am using a NavigationView (each option is a fragment) that has the first option as a fragment with Tabs (so a ViewPager with more fragments). I found a problem when using: viewPager.setAdapter(new AdapterView(getChildFragmentManager())); Basically, using the ViewPager as nested fragment, it only loads 1 page (from the 3 tabs), and it only loads the other pages when I swipe to them (each tab is a fragment with its ContentLoader). I found

Adding a fragment to a dialog

删除回忆录丶 提交于 2019-12-05 15:21:41
问题 I would like to add a fragment to a dialog (it can be either a DialogFragment or a regular Dialog). How do I do that? Here's my DialogFragment: public class MyDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MyDialogFragment2 dialog = new MyDialogFragment2(); View v = inflater.inflate(R.layout.news_articles, container, false); getActivity().getSupportFragmentManager().beginTransaction().add(R.id

Access to getString() in a fragment that implements a viewpager

烂漫一生 提交于 2019-12-05 07:04:18
I am using a nested fragment using SherlockFragment, all works fine. But i am not being able to make viewpager title to string so that i can support multilanguage using string.xml. Here is my code public class schedule_pl extends SherlockFragment { private static String titles[] = new String[] { "Portugal", "Lisbon" , "Azores" }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.main_pager, container, false); // Locate the ViewPager in viewpager_main.xml ViewPager mViewPager = (ViewPager) view

ViewPager with multiple fragment instances of same class

烈酒焚心 提交于 2019-12-04 19:56:18
问题 I am trying to create a ViewPager which contains 5 fragments. 5 fragments "container", so each of them contain 2 fragments. The 4 first fragments have the same layout and belong to the same class. The fifth is from an other class, and there is no problem with that one. The problem is that when the activity launches, only 1 fragment seem to be working (the one at position 0 in viewPager). I tried to return new Fragment() at position 0 in my PagerAdapter, but when I do that it's the 2nd

android.support.v4.app.Fragment: undefined method getChildFragmentManager()

*爱你&永不变心* 提交于 2019-12-04 16:59:57
I'm using ActionBarSherlock and ViewPageIndicator and I tried to implement nested fragments, but the method getChildFragmentManager() is undefined in my android.support.v4.app.Fragments . There are no other errors and ABS and VPI work as expected. I'm not using the Support Library v13, I'm on the latest versions and I've cleaned my projects. A normal android.app.Fragment does not complain about getChildFragmentManager() . I also tried rearranging the support library dependencies (android-support-v4.jar in ABS, VPI and main project referencing it, or android-support-v4.jar in as external jar),

Correct way to remove all (Child) fragments

大憨熊 提交于 2019-12-04 11:39:58
I load a bunch of Child fragments dynamically inside a Parent's Fragment linearLayout (fragmentContainer), then when user clicks a button, I need to remove them all and add new ones. I don't know the exact number of fragments that will be added each time. This is my way of removing all the fragments at once LinearLayout ll = (LinearLayout) view.findViewById(R.id.fragmentContainer); ll.removeAllViews(); Now I can add the new ones using fragment transaction methods. This way of removing all fragments is super easy and works for me better than removing each fragment one by one using remove() But

FragmentPagerAdapter inside Fragment

拈花ヽ惹草 提交于 2019-12-04 03:58:42
I'm having a bit of trouble implementing a design based around multiple ViewPagers. At a high level, I have a FragmentActivity with just a FrameLayout as it's content. I have 3 different Fragments that I want to display. All 3 are full screen and only 1 will be used at a time. Fragment 1 is a basic fragment with some TextViews and ImageViews. Fragment 2 has a ViewPager and a FragmentPagerAdapter that feeds it several simple fragments. Fragment 3 has a ViewPager and a FragmentPagerAdapter that feeds it several simple fragments (that are different from Fragment 2) In my FragmentActivity onCreate

Adding a fragment to a dialog

那年仲夏 提交于 2019-12-04 01:31:35
I would like to add a fragment to a dialog (it can be either a DialogFragment or a regular Dialog). How do I do that? Here's my DialogFragment: public class MyDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MyDialogFragment2 dialog = new MyDialogFragment2(); View v = inflater.inflate(R.layout.news_articles, container, false); getActivity().getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, dialog).commit(); return v; } } Here's news_article.xml: <FrameLayout xmlns:android="http:

Getting reference to nested fragment from FragmentTabHost

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 15:22:01
问题 In my application, I use an Activity which holds one Fragment with FragmentTabHost and hence all its tabs are nested Fragments . Inside an Activity which holds a Fragment with its nested Fragment , we may get a reference to attached one using onAttachedFragment() . But how to get a reference to nested Fragment from FragmentTabHost ? 回答1: Well, exploring the source code of FragmentTabHost I've found that when it adds a fragment tab, it assignes a tag of TabSpec to nested Fragment . So to get