开发者

set Different drawables to Group and Child list when clicked

I am searching around about expandable list view in android. so, we know that there's group-list and child-list... I want to ask if it's possible, if I want a different drawables between group and child list, when they're clicked...

e.g.the group will be red and child will be blue whe开发者_StackOverflow中文版n clicked.

Thank you


You can easily change the drawable for an item that is pressed using state list drawables. But the state of group item should not be changed automatically when the child item state is changed. So it's your task to change the group item state.

But be careful solving this task. List items are rendered by a list adapter and that rendering must be based on the state of items inside the adapter. So, in child items click listener you should change the state of an appropriate group object (something like group.pressed=true, where 'pressed' is a member of your group class) and call adapter.notifyDataSetChanged. And in getView method of the adapter you should analyze that property and configure the group item drawable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜