android-viewpager2

ViewPager2 with horizontal scrollView inside

柔情痞子 提交于 2020-08-25 07:02:29
问题 I implemented the new ViewPager for my project. The viewPager2 contains a list of fragment private class ViewPagerAdapter extends FragmentStateAdapter { private ArrayList<Integer> classifiedIds; ViewPagerAdapter(@NonNull Fragment fragment, final ArrayList<Integer> classifiedIds) { super(fragment); this.classifiedIds = classifiedIds; } @NonNull @Override public Fragment createFragment(int position) { return DetailsFragment.newInstance(classifiedIds.get(position)); } @Override public int

Android ViewPager2 FragmentStateAdapter shows Menu from every Fragment

守給你的承諾、 提交于 2020-08-20 14:22:11
问题 i have an activity with bottom navigation view with 3 Fragments associated. One of them is a Fragment with a ViewPager2 that uses a FragmentStateAdapter. Inside the createfragment(int position) method of the Adapter I return a couple Instances of another Fragment which has an Options Menu and inside it's onCreate() i call setHasOptionsMenu(true). The Problem is that on initialization of the adapter, the menu from all fragments are visible not just the menu of the currently visible fragment.

Viewpager2 in fragment of bottomNavigation: NullPointerException

ε祈祈猫儿з 提交于 2020-08-10 19:35:10
问题 I have 3 fragments used in bottom navigation in Main Activity. In one of the fragments, I have screenslidepagefragment in viewpager2 which has 3 buttons. When I click on any of these 3 buttons I have this error E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.headlines, PID: 3209 java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.lifecycle.LiveData com.example.headlines.Model.NewsViewModel.getData(java.lang.String)' on a null object reference at com.example

FragmentStateAdapter for ViewPager2 notifyItemChanged not working as expected

做~自己de王妃 提交于 2020-08-07 07:53:33
问题 I am using ViewPager2 with FragmentStateAdapter and i am calling notifyItemChanged(position). But as expected createFragment method not calling again. Is it is the intended behavior or bug, what should I do My Code is class EEditionPagerAdapter( fragmentManager: FragmentManager, lifecycle: Lifecycle, private var date: String ) : FragmentStateAdapter(fragmentManager, lifecycle) { private var menuList = emptyList<EEditionMenu>() override fun getItemCount(): Int = menuList.size override fun

BottomSheet + ViewPager2 drag to hide not works

自闭症网瘾萝莉.ら 提交于 2020-08-01 04:53:52
问题 I got troubles and I thinks its CoordinatorLayout's fault but not sure. I'm using ViewPager2 inside a ConstraintLayout and I use the CoordinatorLayout like BottomSheet. But when I drag to hide it not works good. I replaced the ViewPager2 by ViewPager and it works well. I hope you can help me. This is my XML file. <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http: