放在右侧的Andr​​oid的ExpandableListView的指标放在、指标、oid、Andr

2023-09-13 01:34:30 作者:与君歌。

我必须从左边的指示器移动(因为平面图像)到右侧。我不能也成功,因为expandableviewlist里面的片段,而不是内部的整个活动。任何想法?谢谢!

I have to move the indicator from the left to the right (because of the plane image). I couldn't succeed also because the expandableviewlist is inside a fragment and not inside a whole activity. Any idea? Thanks!

推荐答案

我不知道一个办法做到这一点从XML,但我要告诉你一个方法,使动态尽在您的适配器。

I don't know a way to do that from XML but i'll tell you a way to do so dynamically in your adapter.

首先,你必须从你的XML中删除组指标

First you have to remove group indicator from your xml

 <ExpandableListView [...] 
    android:groupIndicator="@null" />

然后在你父母的布局在布局的正确位置添加一个ImageView的。

Then in your layout of the parent add an imageview in the right position of your layout.

然后在你的自定义适配器执行以下操作

Then in your custom adapter do the following

public View getGroupView(int groupPosition, boolean isExpanded,
        View convertView, ViewGroup parent) {
  ...

    if (isExpanded) {
        groupHolder.img.setImageResource(R.drawable.group_down);
    } else {
        groupHolder.img.setImageResource(R.drawable.group_up);
    }
  ...

}
 
精彩推荐