【问题标题】:make some listView's rows invisible使某些 listView 的行不可见
【发布时间】:2015-06-13 23:52:42
【问题描述】:

在我的 Activity 中,我在这里通过某人的帖子创建了一个 listView

每个 listView 的 row 都包含 TextView 和 Button

在某些情况下,我想在运行时制作几行按钮不可见,但我不明白怎么做。

for (int listIndex = 0; listIndex < booksNamesList.size(); ++listIndex) {

    // get the book name from the list and add it to the listAdapter

    String strBookName = booksNamesList.get(listIndex).getBookText().toString();

    m_listAdapter.add(strExperience);

    // TODO:
    // if *anyCondition*, disable the button for the listIndex row.

}

m_listView.setAdapter( m_listAdapter );

注意:m_listView 是 ListView 的对象,m_listAdapter 是 ArrayAdapter 的对象。

请帮忙,谢谢!

【问题讨论】:

    标签: listview button android-activity android-studio android-arrayadapter


    【解决方案1】:

    我通过使用 ViewHolder 模式成功地做到了这一点。 stackoverflow 中有一些例子,所以一点也不难。 在 View Holder 模式中,您应该定义您的视图,并且每个列表行都会调用一个名为“getView”的方法。然后,很容易处理行..您可以将视图可见性设置为 GONE 或其他任何内容:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2023-04-11
      • 2019-09-12
      • 1970-01-01
      • 2011-12-10
      相关资源
      最近更新 更多