0

我的目标是根据单个 if 条件更改每个表格行中包含的布局的可见性。我更改了代码 onResume() 方法。但我看不到第二个表格。即使我打印了日志。我只有 View.Visible。

<?xml version="1.0" encoding="utf-8"?>
    <layout 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"
        tools:context="com.aqualloys.pidmeter.SetupActivity">

        <data>

            <variable
                name="presenter"
                type="com.aqualloys.pidmeter.SetupActivity.SetupActivityPresenter" />

        </data>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar" />


            <TableLayout
                android:id="@+id/permission_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/toolbar"
                android:shrinkColumns="0, 1, 2">

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <RelativeLayout
                        android:id="@+id/usage_access_container"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        app:layout_widthPercent="50%">

                        <include
                            android:id="@+id/usage_access_normal"
                            layout="@layout/permission_normal"
                            android:visibility="visible"
                            app:description="@{@string/allow_access_desc_txt}"
                            app:image="@{@drawable/ic_usage_acces_icon}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/allow_access_txt}" />

                        <include
                            android:id="@+id/usage_access_enable"
                            layout="@layout/permission_enable"
                            android:visibility="gone"
                            app:description="@{@string/allow_access_desc_txt}"
                            app:image="@{@drawable/ic_usage_acces_icon}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/allow_access_txt}" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/dev_admin_container"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@+id/usage_access_container"
                        android:padding="5dp"
                        app:layout_widthPercent="50%">

                        <include
                            android:id="@+id/dev_admin_normal"
                            layout="@layout/permission_normal"
                            android:visibility="visible"
                            app:description="@{@string/activate_admin_desc_txt}"
                            app:image="@{@drawable/accessibility}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/activate_admin_txt}" />

                        <include
                            android:id="@+id/dev_admin_enable"
                            layout="@layout/permission_enable"
                            android:visibility="gone"
                            app:description="@{@string/activate_admin_desc_txt}"
                            app:image="@{@drawable/accessibility}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/activate_admin_txt}" />

                    </RelativeLayout>

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <RelativeLayout
                        android:id="@+id/def_launcher_container"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_below="@+id/usage_access_container"
                        android:padding="5dp"
                        app:layout_widthPercent="50%">

                        <include
                            android:id="@+id/def_launcher_normal"
                            layout="@layout/permission_normal"
                            android:visibility="visible"
                            app:description="@{@string/def_launcher_desc_txt}"
                            app:image="@{@drawable/accessibility}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/def_launcher_title}" />

                        <include
                            android:id="@+id/def_launcher_enable"
                            layout="@layout/permission_enable"
                            android:visibility="gone"
                            app:description="@{@string/def_launcher_desc_txt}"
                            app:image="@{@drawable/accessibility}"
                            app:presenter="@{presenter}"
                            app:title="@{@string/def_launcher_title}" />

                    </RelativeLayout>

                </TableRow>

            </TableLayout>

            <Button
                android:id="@+id/submit_btn"
                android:layout_width="match_parent"
                android:layout_height="@dimen/proceed_btn_height"
                android:layout_alignParentBottom="true"
                android:background="@color/colorPrimary"
                android:onClick="@{(view) -> presenter.onClick(view)}"
                android:text="@string/complete_setup_btn_txt"
                android:textColor="@color/colorAccent"
                android:textSize="@dimen/primary_txt_size" />


        </RelativeLayout>
    </layout>
4

0 回答 0