亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - ListView如何同時修改選中item的背景色和item中ImageView的背景圖片,TextView的字體顏色
天蓬老師
天蓬老師 2017-04-18 10:40:38
0
5
575
天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見證您的進步~~

reply all(5)
Peter_Zhu

Tell me about your solution: In fact, the overall item, ImageView and TextView are all implemented by setting the selector. They are android:background, android:src, android:textColor.
You need to pay attention to two points:

  1. Set the selector in android:textColor, and what needs to be implemented is android:color, not android:drawable.

  2. ListView defaults to the entire item getting focus. If the sub-control does not follow, you need to use android:duplicateParentState="true" to let it get focus.

大家講道理

ImageView and TextView both add this attribute:

android:duplicateParentState="true"
劉奇

If it were me, I would write the logic in getView (maintain a list or something), modify the list when receiving the selection event, and then call notifyDataSetChanged. Because listView itself is designed to cache items, modifying a single itemView will cause many problems.

Peter_Zhu

Provide a new idea for your reference, use the event distribution method dispatchTouchEvent() or onTouchEvent() to handle it. In the problem you described, when the user clicks on the Item, its corresponding parent layout, ImageView, and TextView can be obtained to the distributed event, but do not intercept it in the event method, so that the background and color values ??of different controls can be changed as you like.

PHPzhong

IamgeView and textView always have a parent layout, right? Then you set up the click monitoring of this parent layout. If it is monitored, can you modify the image or text?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template