gpt4 book ai didi

android - 如何禁用 BaseExpandableListAdapter 中某些项目的扩展

转载 作者:太空宇宙 更新时间:2023-11-03 12:51:03 24 4
gpt4 key购买 nike

我想禁用 ExpandableListView 中某些项目的可扩展性.

到目前为止,我知道可以通过 ExpandableListView 来完成但我认为控制要显示的内容/为什么/不从 ListView 显示的内容并不好 - 此任务属于适配器,我想禁用可扩展性。

那么如何从扩展 BaseExpandableListAdapter 的类中做到这一点? ?

到目前为止,我已经尝试将 convertView 可见性设置为 View.GONE 但它不起作用(即它显示了一些奇怪的 View ,空的但不是 查看.GONE)

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if (null == convertView) {
convertView = inflater.inflate(R.layout.system_status_child, parent, false);
}

Item item = systemStatus.get(groupPosition);

if(item.isStatusOk()){
convertView.setVisibility(View.GONE);
}
else{
convertView.setVisibility(View.VISIBLE);
((TextViewMuseo)convertView).setText(item.getChild_text());
}

return convertView;
}

system_status_child.xml 如下所示:

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/system_status_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some text" />

最佳答案

只返回 0,因为子项对这些组进行计数:

@Override
public int getChildrenCount(int groupPosition) {
if (groupPosition == 0 || groupPosition == 1) {
return 0;
} else {
// return normal children count
}
}

关于android - 如何禁用 BaseExpandableListAdapter 中某些项目的扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30984809/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com