大家好
想請教個問題,spannablestring這個可以讓textview顯示文+圖
但現在我有一個listview,裡面也放個textview,可是卻顯示不出文+圖的效果
下面是我的code
[code]
ListView listview01;
SpannableString putimage()
{
SpannableString spans = new SpannableString("TEST");
Drawable dra = getResources().getDrawable(R.drawable.win);
dra.setBounds(0, 0, dra.getIntrinsicWidth() , dra.getIntrinsicHeight());
ImageSpan span = new ImageSpan(dra,ImageSpan.ALIGN_BASELINE);
spans.setSpan(span, 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spans;
}
ArrayList<HashMap<String,String>> mlist =
new ArrayList<HashMap<String,String>>();
HashMap<String,String> item = new HashMap<String,String>();
item.put("test", putimage().toString());
mlist.add(item);
adapter=new SimpleAdapter(this, mlist,
R.layout.list_format_layout,
new String[] {"test"},
new int[] {R.id.imageView1});
listview01.setAdapter(adapter);
[/code]