大家好
想请教个问题,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]