【问题标题】:Android : Dynamic fill contents of viewAndroid:动态填充视图内容
【发布时间】:2014-07-06 18:25:54
【问题描述】:

假设我有一个如下图所示的 Android 应用。

MainActivity(左)我有一个 ListView,例如有 50 个项目。
每个项目都有一个详细信息页面(右),并且所有项目的详细信息页面具有相同的格式。

每次我选择一个项目时,如何将相关内容填充到 item i 的详细布局?

以及保存我的内容的最佳解决方案(数据结构)是什么?

【问题讨论】:

    标签: android android-activity


    【解决方案1】:

    我认为是的,您可以在其中使用 FrameLayout 和两种布局。一个是可见的,另一个是不可见的。但最好使用 Android Fragments。 如果使用 FrameLayout 或 Linear:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <LinearLayout
            android:id="@+id/list"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible"></LinearLayout>
    
        <RelativeLayout
            android:id="@+id/detailed"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="visible"></RelativeLayout>
    
    </FrameLayout>
    

    【讨论】:

    • 您可以使用任何布局来代替 FrameLayout。
    • 我的问题已被编辑。我想使用除主布局外的 1 个布局。主要问题是我可以拥有许多具有相同布局的不同内容吗? (这里我指的是细节布局)
    猜你喜欢
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 2011-03-03
    • 2021-05-13
    • 2011-05-01
    相关资源
    最近更新 更多