我有一些需要更改背景的旋转器。所以,我有这个xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/iconodesplegableactivar"
android:state_enabled="true"/>
<item android:drawable="@drawable/iconodesplegable"
android:state_enabled="false" android:state_window_focused="false"/>
</selector>
我在布局文件中使用Spinner设置没有问题,但是有些Spinner是动态生成的。
如何在动态生成的Spinner中使用xml?setBackground()方法不允许将xml作为参数设置,并且我无法为xml添加ID。
谢谢!
setBackgroundResource(R.drawable.your_file_name);
。 - Malwinder Singh