【问题标题】:Android listview with expandable list view item带有可扩展列表视图项的 Android 列表视图
【发布时间】:2023-03-08 03:51:01
【问题描述】:

我想要一个包含很少可点击元素的列表视图菜单,并且最后一个元素必须是可展开的列表视图项。我的意思是当我点击最后一个元素时,应该会展开一个额外的位置。

【问题讨论】:

    标签: android list layout view adapter


    【解决方案1】:

    你有三个选择。

    • 使用 ExpandableListView ,其中每个组项都没有子项,最后一个组项会有子项(单击父组时它们会展开),周围有很多例子。

      Example of ExpandableListView

    • 当 getView 调用时,使用 listview 并在最后一项上膨胀视图,您知道何时加载最后一个位置,因为您在函数上收到它。

      Example of listview

    • 如果您有少量项目,请考虑使用线性布局来看起来像列表视图,并为最后一个项目使用另一个线性布局。

    例如

      <LinearLayout android:orientation="vertical">     
    
          <TextView />
    
          <TextView />
    
          <LinearLayout 
              android:orientation="vertical" 
              android:onClik="expand">
    
              <TextView />
    
              <TextView />
    
          </LinearLayout>
    
      </LinearLayout>
    

    【讨论】:

    • 嗨,你能告诉我low 是什么意思吗?喜欢确切的数字吗?
    • @SamzSakerz 回答已编辑。替换为“少量”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多