gpt4 book ai didi

android - 如何在 Android 的 xml 文件中加载特定的布局

转载 作者:搜寻专家 更新时间:2023-11-01 09:00:42 27 4
gpt4 key购买 nike

我不知道我的问题是否正确。这只是我的想法。如果可能,请发表您的意见。我的问题是我有一个 xml 文件。它包含几个布局...

是否可以只加载给定 xml 文件中的某些布局部分??我的确切要求是,请参阅我的 xml 代码,它包含 3 种类型的布局。在java部分,当我点击一个按钮时,只有一些布局被显示而其他的被隐藏,这可能吗???

查看我的xml代码

                 <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" >

<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="122dp"
android:layout_y="208dp" >

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="91dp"
android:layout_y="90dp" >
</RelativeLayout>

</AbsoluteLayout>

最佳答案

像这样在 xml 代码中设置可见性消失并检查它

<android:visibility="gone"> to remove the layout 

并设置

 <android:visibility="invisible">   to make the layout invisible

关于android - 如何在 Android 的 xml 文件中加载特定的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15195916/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com