【问题标题】:How to make a list view populate from the bottom up如何使列表视图自下而上填充
【发布时间】:2015-05-29 17:05:26
【问题描述】:

现在我有一个像

一样填充的列表视图
[top]
1
2
3
4
[bottom]

我希望它像

一样填充
[top]
4
3
2
1
[bottom]

android:stackFromBottom="true" 没有给我想要的东西

【问题讨论】:

    标签: android android-layout listview bottom-up


    【解决方案1】:

    覆盖getItem,而不是返回position 处的数据集条目,而是返回dataset.size() - position - 1 处的条目。例如

    假设数据集由Strings 组成,并且您将它们存储在名为mDataSetArrayList<String>()

     @Override
     public String getItem(int position) {
        return mDataSet.get(dataset.size() - position - 1);
     }
    

    【讨论】:

    • 所以可以说我有一个“提示”数组。我会吗?
    • 覆盖 public Object getItem(int position) { return mTips.length - position - 1; } @Blackbelt
    • 差不多:mTips[mTips.length - position - 1]
    • 我在我的自定义适配器中覆盖了它,但它不起作用:(@Blackbelt
    【解决方案2】:

    参考这个: Is it possible to make a ListView populate from the bottom?

    仅当 ListView 的宽度和高度设置为 match_parent 或 fill_parent。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-05
      • 1970-01-01
      • 2019-07-13
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      相关资源
      最近更新 更多