无法从php获取ListView中的所有数据列表?

时间:2016-12-14 18:49:28

标签: java android listview android-studio

我正在尝试从php文件中获取数据。然后在VendorList.class中将其转换为JSON。并希望使用ListView填充VendorListAdapter。但有些数据缺失,如下面的截图所示。

以下是getView功能代码:

 @Override
public View getView(final int i, View view, ViewGroup viewGroup) {

    final ViewHolder holder;
    if(view==null)
    {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view= inflater.inflate(R.layout.vendor_custom_list,null);

        holder= new ViewHolder();
        holder.textViewName = (TextView)view.findViewById(R.id.cameraManName);
        holder.imageViewCamera=(ImageView)view.findViewById(R.id.cameraManImageView);
        holder.ratingBarCamera = (RatingBar)view.findViewById(R.id.cameraManRatingBar);
        holder.cameraManID = (TextView) view.findViewById(R.id.cameraManID);
        view.setTag(holder);

        return view;
    }
    else
    {
        holder=(ViewHolder)view.getTag();

    }

    holder.textViewName.setText(cameraManName.get(i));
    holder.cameraManID.setText(cameramanID.get(i));
 //   myId = cm_id.get(i);
    holder.imageViewCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            //Toast.makeText(context, "cm_id: " + myId, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(context,CustomProfile.class);
            myId = holder.cameraManID.getText().toString();
            v_name = holder.textViewName.getText().toString();
            String imgUri = cameraManImages.get(i);
            intent.putExtra("cm_id", myId);
            intent.putExtra("v_name",v_name);
            intent.putExtra("imageUri",imgUri);
            context.startActivity(intent);
        }
    });
    ImageLoader.getInstance().displayImage(cameraManImages.get(i),                    holder.imageViewCamera, new ImageLoadingListener() {
        @Override
        public void onLoadingStarted(String imageUri, View view) {

           // Toast.makeText(view.getContext(),imageUri+" started",Toast.LENGTH_LONG).show();
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            //Toast.makeText(view.getContext(), String.format("%s%s", imageUri, failReason.getCause()),Toast.LENGTH_LONG).show();

        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            //Toast.makeText(view.getContext(),imageUri+" complete",Toast.LENGTH_LONG).show();
            //123 holder.imageView.setImageBitmap(loadedImage);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
           // Toast.makeText(view.getContext(),imageUri+" cancelled",Toast.LENGTH_LONG).show();

        }
    });

    // holder.ratingBarCamera.setNumStars(cameraManRating.get(i));
    holder.ratingBarCamera.setRating(cameraManRating.get(i));
    // PicassoHelp.downloadImages(context,images.get(i),holder.imageView);
    // holder.imageView.setImageBitmap(images.get(i)); */
    return view;
}

1 个答案:

答案 0 :(得分:1)

在你的getView

    {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view= inflater.inflate(R.layout.vendor_custom_list,null);

        holder= new ViewHolder();
        holder.textViewName = (TextView)view.findViewById(R.id.cameraManName);
        holder.imageViewCamera=(ImageView)view.findViewById(R.id.cameraManImageView);
        holder.ratingBarCamera = (RatingBar)view.findViewById(R.id.cameraManRatingBar);
        holder.cameraManID = (TextView) view.findViewById(R.id.cameraManID);
        view.setTag(holder);

        return view;
    }

删除该返回,在实际设置值之前返回。