android-viewpager2

Fragment no longer exists for key FragmentStateAdapter with Viewpager2

一世执手 提交于 2021-02-17 21:54:33
问题 I am using ViewPager2 for my project. I need to use nested fragments inside a fragment with viewpager2. it works like charm until I try to navigate between fragments(not nested ones). After the first time navigating between fragments, the application crash with the error explained below. the fragment which contains nested fragments OnCreateView method: View view = inflater.inflate(R.layout.orders_fragment, null); ViewPager2 viewPager = view.findViewById(R.id.childViewPager); TabLayout tabs =

Viewpager2 transistion stuck halfway when slide opened using setCurrentItem

只谈情不闲聊 提交于 2021-02-10 07:37:08
问题 The app uses android viewpager2 (androidx.viewpager2:viewpager2:1.0.0-beta04) to show slides. Each slide have video on its top half and text on its bottom half. Each slide is built using same fragment class (code given below) If slided one by one, slide show works absolutely fine, however if attempted opening 'setCurrentItem', SOMETIMES slide stucks halfway in transistion as shown in image below. Presentation Activity myViewPager2.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);

Viewpager2 and Fragments

拟墨画扇 提交于 2021-02-05 07:14:07
问题 ViewPager2 does not support direct child views I'm trying to transition between fragments using the following code but I get the above error when using viewpager2. Call in fragment 1 to transition to fragment 2: getFragmentManager().beginTransaction().replace(R.id.viewPager2, new q2_fragment()).addToBackStack(null).commit(); Viewpager2 XML in Main Layout: <androidx.viewpager2.widget.ViewPager2 android:id="@+id/viewPager2" android:layout_width="match_parent" android:layout_height="match_parent

Viewpager2 and Fragments

a 夏天 提交于 2021-02-05 07:11:06
问题 ViewPager2 does not support direct child views I'm trying to transition between fragments using the following code but I get the above error when using viewpager2. Call in fragment 1 to transition to fragment 2: getFragmentManager().beginTransaction().replace(R.id.viewPager2, new q2_fragment()).addToBackStack(null).commit(); Viewpager2 XML in Main Layout: <androidx.viewpager2.widget.ViewPager2 android:id="@+id/viewPager2" android:layout_width="match_parent" android:layout_height="match_parent

ViewPager2 adapters - difference between FragmentActivity / Fragment / FragmentManager

让人想犯罪 __ 提交于 2021-01-29 21:15:53
问题 I noticed in this ViewPager2 video that there are 3 different ways of declaring an adapter with Fragment s. What's the difference between them and which 1 should be used for swipe views with tabs using ViewPager2? Option 1 (recommended) class MyFragmentAdapter ( fa: FragmentActivity ) : FragmentStateAdapter(fa) Option 2 class MyFragmentAdapter ( f: Fragment ) : FragmentStateAdapter(f) Option 3 class MyFragmentAdapter ( fm: FragmentManager, l: Lifecycle ) : FragmentStateAdapter(fm, l) 回答1:

How to remove first view pager item in kotlin?

那年仲夏 提交于 2021-01-29 05:29:55
问题 I use View-Pager2 in my application that Which displays several same fragments. I also have a dialog fragment and inside it, I manage view pager items(add and remove items). Every fragment inside the view-pager has an id that saved in the SQLite database. So, My problem is, When I remove the first item of view-pager, It does not delete and still remains but another item removed and when I launch the app again, I see the first item has been removed and everything is ok. Main Activity Class:

Why FragmentStateAdapter not work in ViewPager2? [duplicate]

老子叫甜甜 提交于 2021-01-27 20:13:19
问题 This question already has answers here : Proper implementation of ViewPager2 in Android (7 answers) Closed 1 year ago . Android Studio 3.6 I want in my activity to use 2 fragments inside ViewPager2. Here my activity: import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager2.widget.ViewPager2; public class QRBluetoothSwipeActivity extends AppCompatActivity { private ViewPager2 myViewPager2; private ViewPagerFragmentAdapter myAdapter;

How to load images from url into viewpager2?

百般思念 提交于 2021-01-07 04:12:54
问题 I'm using ViewPager2 in my app to show some images it worked well when I used images from drawable but when i try to load images from links it shows error. I'm new to this so please help me how to load them from url. It throws error at the adapter class as items.size(); refers to null. Item Class public class ImageSlider1_Item { private String imageURL; public ImageSlider1_Item(String imageURL){ this.imageURL = imageURL; } public String getImageURL (){ return imageURL; } } Adapter Class

How to load images from url into viewpager2?

↘锁芯ラ 提交于 2021-01-07 04:12:34
问题 I'm using ViewPager2 in my app to show some images it worked well when I used images from drawable but when i try to load images from links it shows error. I'm new to this so please help me how to load them from url. It throws error at the adapter class as items.size(); refers to null. Item Class public class ImageSlider1_Item { private String imageURL; public ImageSlider1_Item(String imageURL){ this.imageURL = imageURL; } public String getImageURL (){ return imageURL; } } Adapter Class

How to load images from url into viewpager2?

泪湿孤枕 提交于 2021-01-07 04:09:26
问题 I'm using ViewPager2 in my app to show some images it worked well when I used images from drawable but when i try to load images from links it shows error. I'm new to this so please help me how to load them from url. It throws error at the adapter class as items.size(); refers to null. Item Class public class ImageSlider1_Item { private String imageURL; public ImageSlider1_Item(String imageURL){ this.imageURL = imageURL; } public String getImageURL (){ return imageURL; } } Adapter Class