美文网首页
解决recyclerview中使用RadioButton出现状态

解决recyclerview中使用RadioButton出现状态

作者: Loyilin | 来源:发表于2019-02-13 10:54 被阅读0次

在XML中设置drawableStart后,第一次setAdapter后drawable显示不对,在7.0及以上机型上正常

在网上看了很多文章都没有用,最后自己猜想和测试,发现是drawable没有刷新,在代码中重新设置后解决。
贴下代码,希望可以帮助到别人

<RadioGroup
            android:id="@+id/radiogroup"
            android:orientation="horizontal"
            android:gravity="center_vertical|right"
            android:paddingTop="@dimen/d5"
            android:paddingBottom="@dimen/d5"
            android:layout_marginStart="@dimen/d10_Miss_fang"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="@dimen/d40">

            <RadioButton
                android:id="@+id/taskinfo_1rb"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="正常"
                android:textColor="@color/black_color"
                android:button="@null"
                android:drawableStart="@drawable/event_radiobt_selector"
                android:drawablePadding="@dimen/d5"
                android:background="@color/white" />
            <RadioButton
                android:id="@+id/taskinfo_2rb"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginStart="@dimen/d35"
                android:text="异常"
                android:textColor="@color/black_color"
                android:button="@null"
                android:drawableStart="@drawable/event_radiobt_selector"
                android:drawablePadding="@dimen/d5"
                android:background="@color/white"/>
        </RadioGroup>
((RadioButton)helper.getView(R.id.taskinfo_1rb)).setCompoundDrawablesWithIntrinsicBounds(
                        Resource.drawable(R.drawable.event_radiobt_selector), null, null, null);
            

((RadioButton)helper.getView(R.id.taskinfo_2rb)).setCompoundDrawablesWithIntrinsicBounds(
                        Resource.drawable(R.drawable.event_radiobt_selector) , null, null, null);

相关文章

网友评论

      本文标题:解决recyclerview中使用RadioButton出现状态

      本文链接:https://www.haomeiwen.com/subject/fbureqtx.html