简体   繁体   中英

Replace ViewPager in other fragment

I have a viewpager in my main activity, and viewpager contains a few pages (exactly a few fragments). I want to go from my viewpager to another fragment which isn't in viewpager. How can I do this?

Here is my activity_main.xml :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.slpd.Activities.SLPDActivity">

    <com.slpd.SlpdViewPager
        android:id="@+id/viewPager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />

</RelativeLayout>

Why do you want to go to another fragment?

If there is one or more fragments you want to transition to, simply add a new activity which looks like your SLDPActivity and inflates a layout with another ViewPager.

If it is only one fragment you want to transition to, why not simply making it a new activity in the first place?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM