android中为不同的组设置不同的指标

发布于 2024-12-03 11:55:57 字数 409 浏览 5 评论 0原文

我想知道如何在 ExpandableListView 中为不同的组设置不同的指示器。

我尝试过:

if(true condition for a group say groupA)
{
    getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.image));
}

但是上面的代码为视图中的所有组设置了指示器! 我希望所有组都有不同的指标,例如:

groupA 有不同的指标;groupB 有不同的指标;groupC 有不同的指标

,其中 groupA、groupB 和 groupC 有一定数量的孩子。

任何人都可以提出建议吗?

-阿迪亚。

I would like to know how to set different indicators for different groups in ExpandableListView.

I tried :

if(true condition for a group say groupA)
{
    getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.image));
}

but the above code sets the indicator for all the groups in the view !
I want different indicators for all the groups like :

groupA having a different indicator;groupB having a different indicator;groupC having a different indicator

where groupA,groupB and groupC have certain number of children.

Can anyone suggest something ?

-Adithya.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云仙小弟 2024-12-10 11:55:57

在可扩展列表视图中创建不同的指示器。
首先为可扩展的listView创建适配器。
为所有不同的指标创建自定义布局。

现在在你的 getGroupView 方法中

@Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {  
LayoutInflater infalInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


            if (groupPosition == 0) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            } else if (groupPosition == 1) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }else if (groupPosition == 2) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }
}

试试这个这对我有用......
希望这对你有帮助..

To create different indicator in expandable listview.
First of all create Adapter for expandable listView.
Create custom layout for all different indicator.

Now in your getGroupView method

@Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {  
LayoutInflater infalInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


            if (groupPosition == 0) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            } else if (groupPosition == 1) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }else if (groupPosition == 2) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }
}

Try this this is work for me...
Hope this is helpful for you..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文