android-viewpager

How to pass custom object arraylist from activity to fragment with instance

寵の児 提交于 2021-01-29 02:49:23
问题 I am using viewpager and creating fragments and i want to pass the arraylist. So i have tried the below things: MainActivity: private ArrayList<customers> mArrayList = null; ViewPagerAdapter adapter = new ViewPagerAdapter(MainActivity.this.getSupportFragmentManager()); adapter.addFrag(NewCustomer.newInstance(mArrayList ), "NewCustomer"); Now in fragment class i am creating instance: public static final ArrayList<customers> data = new ArrayList<customers>(); public static final NewCustomer

Disable click on tablayout, when setup with viewpager

╄→гoц情女王★ 提交于 2021-01-28 06:16:30
问题 I have a ViewPager (3 items) with some icons. When on first item, the icon is selected, there is possible to swipe to the next item. Etc. After selected second icon, there is possibility to go to the third item of viewpager. I have a page indicator (dots), which is connected with ViewPager by setupWithViewPager. The problem is that I want to set clickable on tablayout to false, and unlock steps if the icon on viewPager is selected. Now all "dots" are clickable and I can go to the all items of

RecyclerView with StaggeredGridLayoutManager in ViewPager, arranges items automatically when going back to fragment

◇◆丶佛笑我妖孽 提交于 2021-01-28 04:55:22
问题 I am using Navigation component in my App, using google Advanced Sample(here). my problem is when going back to a fragment, t he scrolling position does not lost but it rearranges items and moves highest visible items so that top of those item align to top of recyclerview. please see this: before going to next fragment: and after back to fragment: this problem is matter because some times clicked item goes down and not seen until scroll down. how to prevent this behavior? please consider:

making a calculator app and want to update history in second fragment with SharePreferences but second Fragment is not updating

左心房为你撑大大i 提交于 2021-01-07 01:26:35
问题 I am making a calculator app and want to update history in second fragment but not able to find a perfect solution for updating ListView in second fragment. I tried many solutions but none of them worked properly. I'm using ViewPager to swipe between calculator and history fragments . I tired bundle class but if I use bundle in OnCreat method of first Fragment(CalculatorFragment) with ViewPager it shows me blank screen after starting an App & if I use Bundle class in Equal Button it crashes

How to know when fragment actually visible in viewpager

廉价感情. 提交于 2020-12-25 10:59:16
问题 I am using 4 fragments inside a ViewPager ,as ViewPager load the previous and next fragment in advance ,and no lifecycle method is called when navigating between fragments. So is there any way to detect when Fragment is actually visible. Thanks in Advance. 回答1: Of course. Assuming that viewPager is your instance of the ViewPager , use: viewPager.getCurrentItem() . Within your Fragment you can check if its instance is visible to the user like so: @Override public void setUserVisibleHint

ViewPager2 must not be null in NavigationDrawer and SwipeViewTabs

会有一股神秘感。 提交于 2020-12-15 06:48:50
问题 I am trying to link my Navigation Drawer with SwipeView Tabs, the problem is that the logcat tells me that my Viewpager must not be null, I have tried to solve this problem in many ways but could not. PageAdaper.kt class ViewPagerAdapter(fragmanetActivity: TabFragment): FragmentStateAdapter(fragmanetActivity) { override fun getItemCount(): Int = 3 override fun createFragment(position: Int): Fragment { when (position) { 0 -> return FirstFragment() 1 -> return SecondFragment() 2 -> return

ViewPager2 must not be null in NavigationDrawer and SwipeViewTabs

半腔热情 提交于 2020-12-15 06:48:05
问题 I am trying to link my Navigation Drawer with SwipeView Tabs, the problem is that the logcat tells me that my Viewpager must not be null, I have tried to solve this problem in many ways but could not. PageAdaper.kt class ViewPagerAdapter(fragmanetActivity: TabFragment): FragmentStateAdapter(fragmanetActivity) { override fun getItemCount(): Int = 3 override fun createFragment(position: Int): Fragment { when (position) { 0 -> return FirstFragment() 1 -> return SecondFragment() 2 -> return

Adding multiple images to ViewPager

此生再无相见时 提交于 2020-12-08 06:10:35
问题 I'm new to Android programming. I'd like to make a very simple app where you can browse a few predefined images fullscreen. I tried the following tutorial: https://developer.android.com/training/animation/screen-slide.html#viewpager Android is a bit complicated to me with the .xml files for resources etc. I thought XML was just to define the individual resources, but I realized they also act similarly to HTML pages when I want to create a view. I managed to display one image by replacing the

Adding multiple images to ViewPager

给你一囗甜甜゛ 提交于 2020-12-08 06:10:25
问题 I'm new to Android programming. I'd like to make a very simple app where you can browse a few predefined images fullscreen. I tried the following tutorial: https://developer.android.com/training/animation/screen-slide.html#viewpager Android is a bit complicated to me with the .xml files for resources etc. I thought XML was just to define the individual resources, but I realized they also act similarly to HTML pages when I want to create a view. I managed to display one image by replacing the