0
嘿我试图添加图标到我的ListView。 这是如何看起来我的ListAdapter。Android ListView自定义图标
ListAdapter adapter = new SimpleAdapter(this, menuItems,R.layout.list_item,
new String[] { KEY_NAME, Icon }, new int[] {R.id.name, R.id.icon});
setListAdapter(adapter);
这就是我如何得到我的图标
String imgFilePath = ASSETS_DIR + ICON_NAME;
try {
Bitmap bitmap = BitmapFactory.decodeStream(this.getResources().getAssets()
.open(imgFilePath));
Icon.setImageBitmap(bitmap);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我应该如何将图标添加到我的ListView?我试图在互联网上使用一些例子,但它看起来像ListAdaptar和ArrayList是完全不同的方式。
我的列表项xml文件。
<ImageView
android:id="@+id/myicon"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#dc6800"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:paddingBottom="2dip" />
每个列表项目的图标是否不同? –