2012-10-05 173 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

我需要看代碼。 –

相關問題