简体   繁体   中英

Need something Swipe Left from Main Activity to go into another Activity

I am making an Android Launcher, which simply has the App Names (Icons are hidden as I just want it to be very minimalist.

In the main activity, I have a list of all apps installed in a GridView. (I want to change that to show only the selected Favourite apps)

I also have another activity where all apps are shown with Search functionality.

I want to be able to switch from Main Activity to the Full App page, as well as switch back to Main activity with swipes.

So Left swipe should bring app page which has (GridView of apps) swipe right from that page brings me back (hopefully restore the previous activity)

I have tried a few different solutions, none of them is ideal as most do not work, and one only works when Swiping right from the top.

Swipe left-right changes activity

I have tried the first solution provided in the above link

我要向左滑动的主要活动页面 我要向右滑动的应用活动页面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainActivity"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">


<LinearLayout
    android:id="@+id/top_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextClock
        android:id="@+id/clock"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:textSize="40sp" />

    <TextView
        android:id="@+id/dateView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:textSize="20sp" />


</LinearLayout>
<LinearLayout
    android:id="@+id/MainActivityApp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="6">
    <GridView
        android:id="@+id/appGrids"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:numColumns="1"
        android:stretchMode="columnWidth">

    </GridView>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_weight="2">
    <ImageView
        android:id="@+id/setting"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:contentDescription="@string/app_name"
        app:srcCompat="@android:drawable/ic_menu_manage"
        />


</LinearLayout>

</LinearLayout>

嗨,看看吧,尝试一下此操作,使手势指向左下右,然后在左侧区域中调用您的下一个活动意图:Android:如何处理从右向左滑动的手势

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