如何在自定义对话框中显示有关位置的回收站视图项?

时间:2017-01-17 06:37:17

标签: android json android-recyclerview

我无法将Recyclerview的项目展示到我的自定义dialog中。 我有一个Recyclerview,其中有一个imageview和3个文本视图,整个数据来自API。

我成功显示了Recyclerview中的所有数据我只想打开一个包含相同数据的对话框是否有人可以帮助我使用此代码? 这是我的adapter课程。

public class ImageUploadAdapter extends RecyclerView.Adapter<ImageUploadAdapter.MyViewHolder> {

    Context context;
    GetImageBySerialResponse getImageBySerialResponse[];
    ImageLoader imageLoader ;
    DisplayImageOptions defaultOptions=new DisplayImageOptions
            .Builder().cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY).displayer(new FadeInBitmapDisplayer(300)).build();

    public ImageUploadAdapter(GetImageBySerialResponse getImageBySerialResponse[],Context context){
        this.context=context;
        this.getJCImageBySerialResponse=getJCImageBySerialResponse;
        ImageLoaderConfiguration configuration=new ImageLoaderConfiguration.Builder(context).
                defaultDisplayImageOptions(defaultOptions).memoryCache(new WeakMemoryCache()).diskCacheSize(100*1024*1024).build();
        ImageLoader.getInstance().init(configuration);
        imageLoader=ImageLoader.getInstance();
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.image_upload_list_item, parent, false);


        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder,final int position) {

        holder.textViewTitle.setText(getImageBySerialResponse[position].title);
        holder.textViewTitleDesc.setText(getImageBySerialResponse[position].comment);
        holder.textViewImageCreateInfo.setText(getImageBySerialResponse[position].createUserId+" "/*+ UtilityOfActivity.convertLongDateToShortDateTime(getImageBySerialResponse[position].createDate)*/);
        //  imageLoader.displayImage(getImageBySerialResponse[position].imageUrl, holder.uploadedImage);
        imageLoader.displayImage(getImageBySerialResponse[position].imageData,holder.uploadedImage);
        ImageLoaderListener(getImageBySerialResponse[position].imageData,holder.uploadedImage);
        holder.textViewEditIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                ImageUploadAdapterClickListener imageUploadAdapterClickListener=new DataSheetImageGallery();
                imageUploadAdapterClickListener.imageUploadAdapterClickListener(context,position,"Edit Icon",imageLoader);

            }
        });
    }

    @Override
    public int getItemCount() {
        return getJCImageBySerialResponse.length;
    }


    public class MyViewHolder extends RecyclerView.ViewHolder {

        CircularImageView uploadedImage;
        TextView textViewTitle, textViewTitleDesc, textViewImageCreateInfo, textViewEditIcon;
        String ImageSerial;
        String strInvoieNo, strCompany, strLocation, strInvoiceDoc, strInvoiceFY, strStatus;
        Button deleteImage;
        public MyViewHolder(View view) {
            super(view);
            textViewTitle = (TextView) view.findViewById(R.id.textViewTitle);
            textViewTitleDesc = (TextView) view.findViewById(R.id.textViewTitleDesc);
            textViewImageCreateInfo = (TextView) view.findViewById(R.id.textViewImageCreateInfo);
            textViewEditIcon = (TextView) view.findViewById(R.id.textViewEditIcon);
            deleteImage=(Button) view.findViewById(R.id.deleteImage);
            uploadedImage = (CircularImageView) view.findViewById(R.id.uploadedImage);

        }
    }

    public void ImageLoaderListener( String  url,final CircularImageView uploadedImage){

        imageLoader.loadImage(url,new ImageLoadingListener(){
            @Override
            public void onLoadingStarted(String imageUri, View view) {
                Log.e("tag", "onLoadingStarted");
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                Log.e("tag", "onLoadingFailed");
            }
            @Override
            public void onLoadingComplete(String imageUri, View view, final Bitmap loadedImage) {
                Log.e("tag", "onLoadingComplete");
                uploadedImage.setImageBitmap(loadedImage);
                uploadedImage.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        final Dialog dialog = new Dialog(context);
                        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        dialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
                        dialog.setCancelable(false);
                        dialog.setCanceledOnTouchOutside(false);
                        dialog.setContentView(R.layout.custom_dialog);
                        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
                        lp.copyFrom(dialog.getWindow().getAttributes());
                        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
                        lp.height = WindowManager.LayoutParams.MATCH_PARENT;


//               /* TextView tvSampleText = (TextView) dialog.findViewById(R.id.custom_dialog_btn_done);
          //     ImageView imageView=(ImageView)dialog.findViewById(R.id.imageView);
//
//
                        TextView dialogtxt1=(TextView)dialog.findViewById(R.id.dialogtxt1);



                        ImageView imageView=(ImageView)dialog.findViewById(R.id.imageView);
                        imageView.setImageBitmap(loadedImage);
                        Button btnDone = (Button) dialog.findViewById(R.id.custom_dialog_btn_done);
                        Button custom_dialog_btn_done1 = (Button) dialog.findViewById(R.id.custom_dialog_btn_done);
                        btnDone.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });

                        dialog.show();
                        dialog.getWindow().setAttributes(lp);

                    }
                });

            }
            @Override
            public void onLoadingCancelled(String imageUri, View view) {
                Log.e("tag", "onLoadingCancelled");
            }
        });
    }
    public interface ImageUploadAdapterClickListener {

        void imageUploadAdapterClickListener(Context context, int position, String calledBy, ImageLoader imageLoader);
    }


}

想要使用Dialog textViewTitle点击已上传的图片,打开textViewTitleDesc 感谢先进的任何建议。

0 个答案:

没有答案