• 7
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

This is my ImageViewHolder that I have mentioned in my adapter class

public static class ImageTypeViewHolder extends RecyclerView.ViewHolder {
    TextView imageCard_Title,imageCard_Description;
    public ImageView imageCardView;

    public ImageTypeViewHolder(View itemView) {
        super(itemView);
        imageCard_Title=itemView.findViewById(R.id.imagecard_title);
        imageCard_Description=itemView.findViewById(R.id.imagecard_description);
        imageCardView=itemView.findViewById(R.id.imagecard_picture);
    }
}

This is the segment of code written in my onBindViewHolder

((ImageTypeViewHolder) viewHolder).imageCard_Title.setText(modelObject.getImageCardTitle());
((ImageTypeViewHolder) viewHolder).imageCard_Description.setText(modelObject.getImageCardDescription());
((ImageTypeViewHolder) viewHolder).imageCardView.setImageResource(modelObject.getImageCardUrl());

I want to create an option which creates a fullscreen view of the imageview which is a part of the RecyclerView item.

This is the code segment in the activity where i'm adding the imagecard element :

chatList.add(new OustChatModel(1,
            "Sample Image Card",
            R.drawable.app_icon,
            "sample description"));

I would like to know what do I do to add a operation that allows the imagecard view to open in a full screen view.

Thanks in advance

In the case of a custom adapter, where you populate your activity/fragment with multiple viewholders, you can make use of an interface to pass data from a fragment to activity.

I provided a interface in the adapter class with a method defined :

public interface onImageClick
{ void onClickImageView(Drawable image);}

Define an object of this interface in this adapter class

onImageClick mObject;

and also declare it in the constructor of the adapter class :

mObject = (onImageClick) this.mCtx;

Now, setup a OnClickListener in the onBindViewHolder()

((ImageTypeViewHolder) viewHolder).imageCardView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mObject.onClickImageView(((ImageTypeViewHolder) viewHolder).imageCardView.getDrawable());
                    }
                });

Write the interface method declared in the activity/fragment where you access Recycler view items :

@Override
public void onClickImageView(Drawable image) {
    //Your operation here
}
  • 0
Reply Report