简体   繁体   English

根据子位置将子对象隐藏在expandablelistview中

[英]Hide child in expandablelistview based on childposition

I need to hide certain children of certain groups based on the groupPosition and the childPosition in an ExpandableListView. 我需要在ExpandableListView中基于groupPosition和childPosition隐藏某些组的某些子级。 But on expanding the group multiple times (especially when the expanded group is not in focus), the value of childPosition that i get is not the same as before. 但是,在多次扩展组时(尤其是在扩展后的组不在焦点上时),我得到的childPosition的值与以前不同。 So a different row gets hidden. 因此,另一行被隐藏了。 Any idea how do i capture the right child everytime? 知道如何每次都能抓住合适的孩子吗?

Right now I setting a different layout with height 0dp because if I setVisibility to View.GONE, it displays the row as blank. 现在,我将高度为0dp的布局设置为其他布局,因为如果将Visibility设置为View.GONE,它会将行显示为空白。

if (convertView == null) {

            if (((m_Budget.budget_planTypeid.equals("budget_single")) || (m_Budget.budget_planTypeid.equals("budget_double")) // hide
                                                                                                                                // pets
                    || (m_Budget.budget_planTypeid.equals("budget_singlefamily")) || (m_Budget.budget_planTypeid.equals("budget_doublefamily"))) && (groupPosition == 4)
                    && (childPosition == 5)) {
                convertView = inflater.inflate(R.layout.blankrow, parent, false);
            } else if (((m_Budget.budget_planTypeid.equals("budget_single")) || (m_Budget.budget_planTypeid.equals("budget_double")) // hide
                                                                                                                                        // child
                                                                                                                                        // care
                    || (m_Budget.budget_planTypeid.equals("budget_singlepet")) || (m_Budget.budget_planTypeid.equals("budget_doublepet"))) && (groupPosition == 3)
                    && (childPosition == 6)) {
                **convertView = inflater.inflate(R.layout.blankrow, parent, false);**
            } else {
                convertView = inflater.inflate(R.layout.budget_list_rowitem, parent, false);
            }

In bold is the layout of the blank row. 粗体字是空白行的布局。 else I set a usual layout 否则我会设置通常的布局

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM