0

我想在单击特定组时更改组上的图像。我创建了自己的自定义基本适配器来扩展可扩展列表。在里面getGroupView我有以下代码来更改扩展组上的图像。但是在扩展时,图像在未扩展的组中发生变化。

有什么解决办法吗?

public View getGroupView(int groupPosition, boolean isExpanded, 
                         View convertView, ViewGroup parent) {
    ImageView categoryImage = (ImageView)  
    convertView.findViewById(R.id.menu_category_image);
    category.setText(subItems.get(groupPosition).getCategoryName());
    if(isExpanded) {
        categoryImage.setImageResource(R.drawable.dn_arrow);
    } else 
        categoryImage.setImageResource(R.drawable.right_arrow);
    return convertView;
}
4

2 回答 2

5
((ImageView) convertView.findViewById(R.id.image_group_indicator))
       .setImageResource(isExpanded?R.drawable.arrowup:R.drawable.arrowdown);
于 2013-07-04T07:36:18.210 回答
2

尝试这个..

list.setOnGroupClickListener(new OnGroupClickListener() 
{
            public boolean onGroupClick(ExpandableListView parent, View v,  int groupPosition, long id) 
            {
    //do your stuff here           
                 return false;
           }
        }
   });

有关更多信息,请尝试以下链接,在这里您将获得一些信息......

http://qtcstation.com/2011/03/working-with-the-expandablelistview-part-1/

或者

http://androidtrainningcenter.blogspot.in/2012/07/android-expandable-listview-simple.html

或者

http://www.coderzheaven.com/2011/04/10/expandable-listview-in-android-using-simpleexpandablelistadapter-a-simple-example/

这可能会帮助你............

于 2012-09-19T16:50:05.293 回答