下面是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:checkMark="@drawable/checking_icon"
android:orientation="vertical"
android:padding="8dp"
android:textSize="18sp" />对于上述xml中的@drawable/checking_icon:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/enable_32" android:state_checked="true"/>
<item android:drawable="@drawable/disable_32"/>
</selector>如何程序化地创建上述两个xmls?
发布于 2013-12-27 21:41:56
您可以简单地通过扩展XML文件来创建CheckedTextView,如下所示
LayoutInflater.from(context).inflate(R.layout.myfile, null);应该就是这样了。如果你想设置这个可绘制的,可以这样做
checkedTextView.setCheckMarkDrawable(getResources().getDrawable(R.drawable.filename));https://stackoverflow.com/questions/20801448
复制相似问题