2012-10-05 174 views
2

我有ArrayList,它将加载简单的xml textview作为项目。在TextView中我有drawableleft,但我无法弄清楚,如何改变这个图像?在适配器或?因为现在有办法在字符串列表中插入可绘制对象。TextView在ListView中更改DrawableLeft

我有一个像负荷项目:

items = new ArrayList<String>(); 
items.add(Some String item); 

这是适配器

ArrayAdapter<String> List = new ArrayAdapter<String>(this, R.layout.item_text, items); 
ListView mylist = (ListView) findViewById(android.R.id.list); 
mylist.setAdapter(List); 

和我的TextView项目

<TextView 
android:id="@+id/item" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:drawableLeft="@drawable/folder" 
android:drawableEnd="@drawable/next" > 
</TextView> 

回答

0

扩展ArrayAdapter类并重写getView()方法。此方法返回在加载数据时将放置在每行中的View。按照您的意愿使用它来更改图像。

+1

是的,它工作正常。如果有人需要我可以显示代码方法 –

+1

我需要看代码。 –

相关问题