我正在使用JSON请求制作电影应用等。所以我有一个列表视图,显示电影数据,如演员,导演,家长指南,IMDB等。以下是将这些数据放入listview的代码:
maxX
..这就是我有IMDB图标的问题,所以它来自ListAdapter adapter = new SimpleAdapter(
movies.this, contactList,
R.layout.list_new, new String[]{"name", "actors",
"story", "imrating", "genre","guide", "director"}, new int[]{R.id.title,
R.id.actors_txt, R.id.story, R.id.rating, R.id.genre,R.id.parental, R.id.director_txt, R.id.year, R.id.imageView8, R.id.imageView10, R.id.backgroundimg});
lv.setAdapter(adapter);
6.2(来自JSON),但图像本身来自listview布局文件中imageview中的app。
<imdbicon>
我希望在列表视图中使用这三个,但我无法确定如何
答案 0 :(得分:0)
您可以创建SimpleAdapter
的子类并覆盖setImageView
以根据您的文字获取图片:
ListAdapter adapter = new SimpleAdapter(
movies.this, contactList,
R.layout.list_new, new String[]{"name", "actors",
"story", "imrating", "genre","guide", "director"}, new int[]{R.id.title,
R.id.actors_txt, R.id.story, R.id.rating, R.id.genre,R.id.parental, R.id.director_txt, R.id.year, R.id.imageView8, R.id.imageView10, R.id.backgroundimg}) {
@Override
public void setViewImage(ImageView v, String value) {
// here you put code to take your "value" string
// and get your image, for example using Picasso
// or Glide, and putting it in the "v" ImageView.
}
};