我正在使用毕加索图书馆从网上填写图片。 我正在使用自定义适配器....在该适配器的GetView()方法中,我希望每个图像都显示在我创建的layout.XML文件中,名为mov_poster.xml,其中只有一个ImageView :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/individual_movie"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
我很难充气这个XML并将图像放在ImageView中。它应该是图像行,但每次我启动我的应用程序时,它只是空白。这是我的适配器的样子:
public class CustomGridAdapter extends BaseAdapter {
private Context mContext;
private String[] mThumbIds;
public CustomGridAdapter(Context context, String[] items) {
this.mContext = context;
this.mThumbIds = items;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null){
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.mov_poster, parent, false);
}
ImageView imageView = (ImageView)convertView.findViewById(R.id.individual_movie);
Picasso.with(mContext).load(My image URL).fit().into(imageView);
return convertView;
}}