【问题标题】:Hiding group indicator in Expandable List view在可展开列表视图中隐藏组指示器
【发布时间】:2014-04-28 11:07:10
【问题描述】:

我想在我的所有列表元素的 n 可展开列表视图中隐藏组展开/折叠指示器,而是显示一个图像来代替指示器。我使用这个使指示器颜色透明:

 android:groupIndicator="@android:color/transparent

但这不会让我将图像放置在指示器以前的位置,所以我需要一种新的方法来做到这一点。

【问题讨论】:

  • (在 Java 中,当您初始化视图时)如果 elv 是您的 ExpandableListView:elv.setGroupIndicator(null);

标签: android android-layout android-listview expandablelistview expand


【解决方案1】:

实现你自己的BaseExpandableListAdapter:

public class MyExpandableListAdapter extends BaseExpandableListAdapter {

    ... 

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View rowView = inflater.inflate(R.layout.list_group_item, null);
        return rowView;
    }

    ...

}

list_group_item 应包含所需的组指示符图像。并且不要忘记禁用原生指示:

expandableListView.setGroupIndicator(null);

【讨论】:

  • 谢谢@fraggjkee 这就是我要找的。​​span>
【解决方案2】:

你需要设置 android:groupIndicator="@null"

【讨论】:

    猜你喜欢
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 2015-02-09
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 2017-05-06
    • 1970-01-01
    相关资源
    最近更新 更多