fragmentpageradapter

Disable swipe in fragmentPagerAdapter? - android

南楼画角 提交于 2020-08-24 06:38:34
问题 Hey guys i have a fragmentPagerAdapter with 3 fragments in it. How would i disable the swiping between the 3 fragments so the user only uses the tabview to go between fragments? Cheers! private class ViewPagerAdapter extends FragmentPagerAdapter { ArrayList<Fragment> fragments = new ArrayList<>(); ArrayList<String> tabTitles = new ArrayList<>(); public ViewPagerAdapter(android.support.v4.app.FragmentManager fragmentManager) { super(fragmentManager); } @Override public Fragment getItem(int

Android: limit fragments loading with a viewPager

半城伤御伤魂 提交于 2020-02-02 02:47:06
问题 I have 3 fragments that are managed by an FragmentPagerAdapter, set to a viewPager. I want to load fragments one by one, but when the onCreate method of FragmentActivity is executed, the 2 first fragments are executed (onCreateView method). I have tried to limit fragments loading with the setOffscreenPageLimit method but nothing change. mPagerAdapter = new MyPagerAdapter(super.getSupportFragmentManager(), fragments); pager = (ViewPager) super.findViewById(R.id.tabviewpager); pager

FragmentPagerAdapter deprecated

℡╲_俬逩灬. 提交于 2020-01-22 17:12:56
问题 Since API 27 FragmentPagerAdapter is deprecated. What's the best alternative to use for this? In my case, I understand some thing like super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) would need to be used, but I don't know where within my code this needs to go. I got these imports in my class: import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter but FragmentPagerAdapter in class MyViewPagerAdapter(manager: FragmentManager) :

Trouble with ViewPager displaying Fragments

梦想的初衷 提交于 2020-01-14 13:18:29
问题 I am trying to get a fragment with three tabs displayed using ViewPager. Initially I used to instantiate the fragment from the Activity using FragmentMgr, this worked fine. When I converted this navigation using ViewPager, this Fragment is no longer displayed. MainActivity.java When I initiate Fragment like this, it gets displayed. eg: LaunchListFragment fragment = new LaunchListFragment(); fragment.newInstance(LIST_TYPE); getSupportFragmentManager().beginTransaction() .add(R.id.item_detail

Android fragment nested in another fragment: getParentFragment() returns 0

主宰稳场 提交于 2020-01-02 10:17:23
问题 Basically the situation is like this: I have an Activity , which displays a three Fragments within a FragmentPagerAdapter , and within one of these Fragment , I nest another Fragment . I added the fragments like this: fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(rootView.getId(), new MainPageFragment(), "lpt2"); fragmentTransaction.commit(); When I try to call getParentFragment() inside of MainPageFragment() , it returns null . How can that be? I

Android fragment nested in another fragment: getParentFragment() returns 0

ε祈祈猫儿з 提交于 2020-01-02 10:17:13
问题 Basically the situation is like this: I have an Activity , which displays a three Fragments within a FragmentPagerAdapter , and within one of these Fragment , I nest another Fragment . I added the fragments like this: fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(rootView.getId(), new MainPageFragment(), "lpt2"); fragmentTransaction.commit(); When I try to call getParentFragment() inside of MainPageFragment() , it returns null . How can that be? I

Android FragmentStatePagerAdapter

落花浮王杯 提交于 2019-12-31 10:35:12
问题 I'm working with a FragmentStatePagerAdapter using this example. The MyAdapter class is implemented as follows: public static class MyAdapter extends FragmentStatePagerAdapter { public MyAdapter(FragmentManager fm) { super(fm); } @Override public int getCount() { return NUM_ITEMS; } @Override public Fragment getItem(int position) { return ArrayListFragment.newInstance(position); } } The ListFragment class includes the following method to create a new instance: /** * Create a new instance of

Fragment in ViewPager is not displaying anything in its RecyclerView on rotation

拜拜、爱过 提交于 2019-12-31 01:49:09
问题 I have 4 Fragments in a ViewPager that is integrated with a TabLayout. Each of those Fragments holds a RecyclerView because I'm displaying an unknown amount of list items. The items are loaded by date, so I have two buttons that let you change days, and then the appropriate data in the list items is loaded based on the date that is set. The buttons are part of the outer activity. Everything so far works perfectly BUT once I rotate the device the fragments don't load anything. Nothing is

How to Remove Fragment from FragmentPagerAdapter?

被刻印的时光 ゝ 提交于 2019-12-30 00:37:09
问题 I know there are some topics about this here already but I could not find a solution which I could get to work for my case. I have a working sliding gallery using a custom FragmentActivity and FragmentPagerAdapter which holds a list of Fragments. Within the FragmentActivity is a ImageView "delete". If clicked, the function deleteMedia() is called which then should remove the current Fragment and the following Fragment should be displayed. How would I have to do that in my example?

Intent in AsyncTask for FragmentPagerAdapter

有些话、适合烂在心里 提交于 2019-12-25 20:06:54
问题 I have implemented a FragmentPagerAdapter of 4-lashes, and in each of them I load a fragment with a different view. In one of them, pressing an image executed a AsyncTask to obtain a series of data from a server and loads a new class through an intent on the postExecute() method as follows: //AsyncTask private static class LoadJSON extends AsyncTask<String, Void, String> { protected void onPreExecute() { mProgressItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mProgressItem.setVisible