我正在使用picasso将服务器中的图像加载到列表视图项,如下所示:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View participantView;
if(convertView == null) {
participantView = inflater.inflate(R.layout.participant_item, parent, false);
} else {
participantView = convertView;
}
TextView textView = (TextView) participantView.findViewById(R.id.participantName);
textView.setText(getItem(position).getName());
ImageView imageView = (ImageView) participantView.findViewById(R.id.participantImage);
String profilePic = getItem(position).getProfilePic();
if(!profilePic.equals("None")) {
Log.d("tom.debug", "creating picture for user: " + getItem(position).getName());
Picasso.with(this.context)
.load(urlToProfilePics + profilePic)
.placeholder(R.drawable.sample_0)
.resize(52, 52)
.into(imageView);
} else {
//load the place holder into the image view
Picasso.with(this.context).load(R.drawable.sample_0);
} …Run Code Online (Sandbox Code Playgroud) 是的,我正在使用Picasso来加载位图.究其原因,我在我的适配器,而在另一个装载位图的一部分解码的URI,和我读到这里是
即使您的URL为空,也应始终致电Picasso.这样它就知道图像视图被回收了.
所以我试过这个....
Bitmap bitMap;
...
Picasso.with(getContext())
.load(bitMap)
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
但我得到了这个错误
无法解析方法'load(android.graphics.Bitmap)'