【问题标题】:Navigation inside TabHostTabHost 内的导航
【发布时间】:2019-05-30 07:22:26
【问题描述】:

我的导航有问题:我使用MvxTabsFragmentActivity 创建了一个选项卡式应用程序,并且一切正常,直到我开始在选项卡内导航;如果我在一个选项卡内导航一个级别,然后更改选项卡,则在第二个选项卡上,我会看到第一个选项卡中的内容。有人遇到过这个问题吗?

我使用TabHost 创建了标签。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
  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"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/actualtabcontent"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_above="@+id/tabContainer"/>

    <LinearLayout android:id="@+id/tabContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

    <TabHost android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white">

        <LinearLayout android:orientation="vertical"
            android:layout_width="match_parent" 
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="7dp"
                android:background="@drawable/gradient_border_top"
                android:orientation="horizontal" />

                <TabWidget android:id="@android:id/tabs"
                     android:orientation="horizontal"
                     android:layout_width="match_parent" 
                     android:layout_height="56dp"
                     android:layout_weight="0"
                     android:background="@color/white" />

                <FrameLayout android:id="@android:id/tabcontent"
                     android:layout_width="0dp"
                     android:layout_height="0dp"
                     android:layout_weight="0" />
              </LinearLayout>
        </TabHost>
    </LinearLayout>
</RelativeLayout>

每次我在标签内导航时,都会替换实际标签内容的内容。

预期导航:

选项卡 A:A1 -> A2。

选项卡 B:B1 -> B2。

在选项卡之间切换应显示所选选项卡的内容

【问题讨论】:

    标签: android xamarin tabs mvvmcross


    【解决方案1】:

    '您需要在移动到下一个选项卡时清除缓存。 如果您使用 volley 从服务器获取数据,请使用'

    stringRequest.setShouldCache(false);
    

    '在将你的 stringrequest 传递给 requestqueu 之前。'

    '如果你正在使用其他东西,那么在加载新数据之前找到一种清除缓存的方法。'

    '希望你能得到答案,如果没有请解释你的问题。'

    【讨论】:

    • 我没有使用 volley 库。该应用程序的架构是使用 MvvmCross 制作的,我在 Core 项目中创建了一个自定义 HttpWrapper 类,用于调用服务器。
    • 我认为这应该对你有所帮助。 Click
    • 它不适合我的问题。还是谢谢。
    猜你喜欢
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多