Android ListView with RadioButton/CheckBox in singleChoice mode and a custom row layout

前端 未结 2 622
眼角桃花
眼角桃花 2020-12-06 04:02

I have a ListView, which is in singleChoice mode. All I want is to display a RadioButton to the side, that when clicked highlights to say it is selected, and when a differen

2条回答
  •  情歌与酒
    2020-12-06 04:21

    I used dbm's answer and it worked fine for me except one thing:

    You should initiate CheckedTextView in onAttachedToWindow() method, not in onFinishInflate(). This is because onAttachedToWindow() called before onFinishInflate() and using the solution above you will never see any drawable in CheckedTextView—it is null when onAttachedToWindow() called.

提交回复
热议问题