android-viewpager

In the “ActionBarTabsPager” tutorial, getActivity returns null

不羁的心 提交于 2020-01-25 12:08:13
问题 I have successfully implemented the tutorial: http://developer.android.com/reference/android/support/v4/view/ViewPager.html, as a Tab'ed viewpager activity with fragments on each tab. Each Fragment maintains various UI TextFields etc and everything is working fine with the exception of getActivity(), which returns null when called from any of the fragments. UPDATE: Read this, then please see my own answer below that broadens the scope regarding the cause of this error. Continued: BUT, the

Android Switching between Viewpager produces Android crash

ぃ、小莉子 提交于 2020-01-25 05:55:52
问题 I have five fragments in an View pager. One of them is a BarcodeFragment BarcodeFragment and I am getting a very weird android crash when I swipe between ViewPager fragments quickly. The crash Im getting is on the android side. This is the log. java.lang.IndexOutOfBoundsException: Invalid index 7, size is 7 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.set(ArrayList.java:481) at android.support.v4.app.FragmentManagerImpl.makeInactive

how to avoid hiding the tabs when scrolled down?

亡梦爱人 提交于 2020-01-25 03:39:09
问题 I have implemented viewpager with TabLayout. Each tab is a Fragment. I think the default behavior of Tabs is that they are hidden when user scrolls down and gets visibility when scrolled up. I wont have much content to make use of the tabs space too. So I want to show the tabs always. How can I avoid hiding the Tabs when user scrolls down ? Here is my TabLayout with ViewPager: <android.support.design.widget.AppBarLayout android:id="@+id/myAppBarLayout" android:layout_width="match_parent"

ViewPager using Views instead of Fragments

二次信任 提交于 2020-01-24 20:17:06
问题 I've a ViewPager which now uses Views instead of Fragments to display each tab. Every single tab, inflates the same layout file. Overview In this ViewPager , I'm supposed to add Mines as Tabs, so basically every tab would correspond to a specific mine (the ones with minerals, not the bomb). Some mines are already unlocked, but some other need to be purchased first, so I added a button to do just this. Problem Fact is, using fragments, it all worked fine, but now I swapped them with Views, I

It returns null when I use getView() to get root View of the Fragment in the ViewPager

泪湿孤枕 提交于 2020-01-24 13:14:32
问题 I have an Activity that have two Fragments and those fragments are presented to user by a ViewPager. So, I created a class extends FragmentStatePagerAdapter for ViewPager's adapter (MainFragsAdapter class) and I overrided some methods of it. I want to get my fragment's instances in my ViewPager from host Activity and get current fragment's root View by getView() method. I got the instances of fragments by typing followings in Activity's onCreate() But getView() of that instance returns null :

OnResume called multiple times inside fragment

怎甘沉沦 提交于 2020-01-24 10:33:06
问题 I have InnerFragment containing RecyclerView, inside MainFragment which is added to ViewPager . When MainFragment gets created while swiping OnResume is called multiple times 1st time : OnResume called once in MainFragment and Once in InnerFragment 2n time : OnResume called once in MainFragment and Twice in InnerFragment 3rd time : OnResume called once in MainFragment and Thrice in InnerFragment Adding MainFragment in ViewPager //Assigning Adapter in ViewPager mViewPager.setAdapter(new

OnResume called multiple times inside fragment

為{幸葍}努か 提交于 2020-01-24 10:33:05
问题 I have InnerFragment containing RecyclerView, inside MainFragment which is added to ViewPager . When MainFragment gets created while swiping OnResume is called multiple times 1st time : OnResume called once in MainFragment and Once in InnerFragment 2n time : OnResume called once in MainFragment and Twice in InnerFragment 3rd time : OnResume called once in MainFragment and Thrice in InnerFragment Adding MainFragment in ViewPager //Assigning Adapter in ViewPager mViewPager.setAdapter(new

ViewPager setOffscreenPageLimit not working when using it as NestedFragment with getChildFragmentManager

为君一笑 提交于 2020-01-23 16:52:21
问题 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

ViewPager setOffscreenPageLimit not working when using it as NestedFragment with getChildFragmentManager

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-23 16:51:07
问题 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

ViewPager with Fragments that contain TableLayouts loads slowly:

落花浮王杯 提交于 2020-01-22 20:02:27
问题 I'm developing an Activity with a ViewPager that contains Fragments (Max 4 fragment each time) when each containing TableLayout . So basically 4 Tables are loaded. This is the code for loading the data into the Fragment which is later attached to the ViewPager : public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT