网格片段中的网格适配器无法正常工作

时间:2016-11-10 17:52:22

标签: android android-layout android-studio android-fragments android-asynctask

我试图让输出frm成为一个异步类,并在一个片段中的网格视图中使用 我确定我的输入是正确的

 public void processFinish(movieList output) {
        String[] movieId=output.getMovieId();
        String[] movieImg=output.getMovieId();
        boolean response=output.getStatus();
        if(response==true){
            GridView gridView = (GridView) view.findViewById(R.id.gridView_cover);
            MovieAdapter = new movieGridAdapter(getActivity(), movieImg);
            gridView.setAdapter(MovieAdapter);
}

GridAdapter

public View getView(int position, View view, ViewGroup viewGroup) {
        ImageView imageView;
        if(view==null){
            imageView= new ImageView(mContext);
            // imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);

        }
        else
        {
            imageView=(ImageView) view;

        }

        Picasso.with(mContext).load(image_base_url+imgs[position]).into(imageView);
        //Log.v(movieGridAdapter.class.getSimpleName(),"http://image.tmdb.org/t/p/w500/"+imgs[position]);

        return imageView;
    }

1 个答案:

答案 0 :(得分:0)

if(view==null){
            view = inflater.inflate(R.layout.YOUR_ADAPTER_LAYOUT, null);
            imageView= new ImageView(mContext);
            // imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    }

您没有为您的gridview夸大布局,因此您看不到任何内容!