我有一个android picasso的问题。我的手机中没有加载某些图像。它只显示与手机不同的黑色页面。其他手机加载所有手机,而其他手机根本没有加载或有些手机丢失。
我正在使用适配器btw
这是我的适配器代码
package com.jc.jcpremiere;
import com.squareup.picasso.Picasso;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class ViewPagerAdapter extends PagerAdapter {
// Declare Variables
Context context;
int[] flag;
String[] rank;
LayoutInflater inflater;
public ViewPagerAdapter(Context context, int[] flag, String[] rank) {
this.context = context;
this.flag = flag;
this.rank = rank;
}
@Override
public int getCount() {
return rank.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.app3x, container, false);
ImageView imgflag = (ImageView) itemView.findViewById(R.id.items); // need this ImageView
Picasso.with(context).load(flag[position]).resize(50, 50)
.centerCrop().into(imgflag); // use ImageView
//imgflag.setImageResource(flag[position]);
((ViewPager) container).addView(itemView);
return itemView;
}
private ImageView findViewById(int items) {
// TODO Auto-generated method stub
return null;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// Remove viewpager_item.xml from ViewPager
((ViewPager) container).removeView((RelativeLayout) object);
}
}