fragmentstatepageradapter

Unable to change the tab icons while using FragmentStatePagerAdapter

放肆的年华 提交于 2019-12-11 20:01:20
问题 Im usign the following code to change the icon of selected tab. Im using view pager with FragmentStatePagerAdapter. tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { if (tab.getPosition() == 0) { viewPager.setSelected(true); tab.setIcon(R.drawable.status); } else if (tab.getPosition() == 1){ tab.setIcon(R.drawable.status); viewPager.setSelected(true); }else if (tab.getPosition() == 2){ tab.setIcon(R.drawable

FragmentStatePagerAdapter returns null views

余生颓废 提交于 2019-12-11 17:26:52
问题 I'm using a FragmentStatePagerAdapter in order to display fragments within a ViewPager, all of these Fragments obey the same layout container(a FrameLayout ) but it's number is changeable over run-time, So that I put all of them into a static List of fragments and pass that list to the FragmentStatePagerAdapter (first time through it's constructor and each time after that I just update the list and notifydatasetchanged ): public class MyPageAdapter extends FragmentStatePagerAdapter { public

Duplicate Menu and Data in Fragments after using FragmentStatePagerAdapter

北城余情 提交于 2019-12-11 12:37:06
问题 I tried so many answers provided by various posts here but nothing worked for me. Problem- I have navigation drawer that has 6 fragments but single activity. Everything worked fine till I changed 1st ranked fragment in drawer. I wanted Swipe tabs inside first fragment. So I used FragmentStatePagerAdapter . Each fragment has its own menu along with MainActivity Menu. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notify the system to allow an

Cannot remove fragment from ViewPager, why?

依然范特西╮ 提交于 2019-12-11 06:43:49
问题 I must be missing something but I cannot remove a fragment from my ViewPager . I store the page titles in an ArrayList : Part of ViewPagerActivity.java (which is a FragmentActivity , the main activity): public static ArrayList<String> mEntries = new ArrayList<String>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); context=this; mEntries.add(" 111"); mEntries.add(" 222"); mEntries.add(" 333"); mEntries.add("

FragmentStatePagerAdapter - getItem

我与影子孤独终老i 提交于 2019-12-11 06:16:46
问题 I know there are several other posts on this topic, but I wanted to paste my code because I believe there may be an error in it that is causing my problem. My FragmentStatePagerAdapter is returning the wrong position, and I am not sure why. Here is the code in my Main activity. Main.java import android.content.Context; import android.content.Intent; import android.graphics.Typeface; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app

Jump to the next fragment on any fragment in FragmentStatePagerAdapter

流过昼夜 提交于 2019-12-11 01:35:40
问题 I am using a FragmentStatePagerAdapter in my app. this is my adapter: private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { List<FeedItem> posts = FeedListFragment.getPosts(); public ScreenSlidePagerAdapter(FragmentManager fragmentManager) { super(fragmentManager); } @Override public Fragment getItem(int position) { FeedItem post = posts.get(position); String url = post.getUrl(); String title = post.getTitle(); String imagUrl = null; if (post.getType() == FeedItem.ARTICLE

FragmentStatePagerAdapter handling getItem() position

让人想犯罪 __ 提交于 2019-12-10 17:55:47
问题 I tried this, but wrong lists get binded to the recyclerview. I tried SparseArray as well, even that doesn't work. getItem() gets called twice when i start Mainactivity. How do I handle the position returned? I tried returning viewpager currentItem, even that doesn't work. MainActivity public class PagerAdapter extends FragmentStatePagerAdapter { int mNumOfTabs; public PagerAdapter(android.support.v4.app.FragmentManager fragmentManager, int tabCount) { super(fragmentManager); this.mNumOfTabs

Fragment already added IllegalStateException in viewpager

混江龙づ霸主 提交于 2019-12-10 14:45:44
问题 I'm using viewpager to display pictures. I just need three fragments basically: previous image to preview, current display image and next image to preview. I would like to just display a preview of previous and next image, it will change to full image when user actually swipe to it. So I'm thinking of just using 3 fragment to achieve this. Code is below: private class ImagePagerAdapter extends FragmentStatePagerAdapter implements ViewPager.OnPageChangeListener { private ImageFragment

ViewPager first fragment shown is always wrong with FragmentStatePager

半城伤御伤魂 提交于 2019-12-10 03:34:30
问题 I am trying to have the same view pager + tabs design as the PlayStore 5.1.x. Here is my layout : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal" android:orientation="vertical"> <com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" android:layout

How do I get SharedPreference object in FragmentStatePagerAdapter?

这一生的挚爱 提交于 2019-12-08 13:15:03
问题 I wanna add an integer dynamically in the getCount() method of custom pager adapter that obviously extends FragmentStatePagerAdapter. return some integer value; I have a counter saved in Shared Preference object and it gets updated with clicks on star images. I wanna return the updated counter value in the mentioned method, so I can generate that many swipe views but the problem is I unable to get Shared Preference object there. This is the only obstacle between my app and the play store, I