【问题标题】:Android ListView or GridView item in xml without adapter没有适配器的 xml 中的 Android ListView 或 GridView 项
【发布时间】:2020-07-15 06:02:12
【问题描述】:

我想创建一个 ListView 并让我的值是静态的。我想我不需要适配器。我需要适配器吗?

    <GridView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="4"
        android:layout_alignParentStart="true">
        <TextView
            android:id="@android:id/text1"
            android
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceListItemSmall"
            android:gravity="center_vertical"
            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
            android:minHeight="?android:attr/listPreferredItemHeightSmall" />
    </GridView>

【问题讨论】:

    标签: android listview adapter android-arrayadapter


    【解决方案1】:

    是的,您可以拥有,但您需要为其添加 ypur 自己的静态数据。

    【讨论】:

    • 如何在 xml 中添加自己的静态数据
    • 您似乎在gridview 或listview 中有textview。因此,您必须为要在列表视图上显示的每个项目创建多个文本视图。
    • 这就是我们使用适配器的原因!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多