代码之家  ›  专栏  ›  技术社区  ›  Hong

如何消除ExpandableListView的警告“无法解析符号'id/andr'”

  •  2
  • Hong  · 技术社区  · 7 年前

    一个应用程序使用 expandablelistactivity ,expandablelistview的使用是基于文档的标准:

    展开列表视图 android:id=“@id/android:list” android:layout_width=“匹配父级” android:layout_height=“0dip” android:layout_weight=“1” android:divider=“@android:color/transparent” android:dividerheight=“5dip” android:layout_margintop=“10dip”> </ExpandableListView> < /代码>

    Android Studio 3.2有以下警告:

    我怎样才能摆脱警告呢?

    <ExpandableListView
        android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:divider="@android:color/transparent"
        android:dividerHeight="5dip"
        android:layout_marginTop="10dip">
    </ExpandableListView>
    

    Android Studio 3.2有以下警告: enter image description here

    我怎样才能摆脱警告呢?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Bevor    7 年前

    这可能是个打字错误。把它改成:

    "@android:id/empty"
    

    "@android:id/list"
    

    也见 https://developer.android.com/reference/android/app/ListActivity

    ListActivity的默认布局由单个, 全屏列表位于屏幕中央。但是,如果你愿意, 您可以通过设置自己的视图布局自定义屏幕布局。 在onCreate()中使用setContentView()。要做到这一点,你自己的观点必须 包含ID为的ListView对象 “@android:id/列表” (或R.ID.LIST) 如果在代码中)

        2
  •  0
  •   Hassan Badawi    7 年前

    我不知道是什么(id=“@id/android:list”)

    给它一个普通的ID(@+ID/AndroidList) 在你的代码中处理它

    但是如果你学习如何使用ExpandableListView 我更喜欢这个链接教程 ExpandableListView Link

    主席先生