error onclicklistener on recyclerview - android

i have a recyclerview and i want to when click on it receive the position and one String and sent to other activity and run it
i dont know where this code has problem.
Mainactivity
#Override
public void onItemClick(int i) {
datamodel clickedItem = postlist.get(i);
Intent detailIntent = new Intent(MainActivity.this, Main2Activity.class);
detailIntent.putExtra(EXTRA_URL, clickedItem.getmTitle());
startActivity(detailIntent);
}
Adapter codes:
public class rrecyclerviewadapter extends RecyclerView.Adapter<rrecyclerviewadapter.myholder> {
private OnItemClickListener mListener;
private Context context;
private List<datamodel>mylist;
public interface OnItemClickListener {
void onItemClick(int i);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.mListener = listener;
}
public rrecyclerviewadapter(Context context, List<datamodel>mylist){
this.context=context;
this.mylist=mylist;
}
#NonNull
#Override
public myholder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View view= LayoutInflater.from(context).inflate(R.layout.each_item,viewGroup,false);
return new myholder(view);
}
#Override
public void onBindViewHolder(#NonNull myholder myholder, int i) {
datamodel datamodel=mylist.get(i);
myholder.eachitemtxt.setText(datamodel.getmTitle());
Picasso.with(context).load(datamodel.getMimageurl()).placeholder(R.drawable.pic3).error(R.drawable.pic4).into(myholder.eachitemimg);
}
#Override
public int getItemCount() {
return mylist.size();
}
public class myholder extends RecyclerView.ViewHolder {
private TextView eachitemtxt;
private ImageView eachitemimg;
public myholder(#NonNull final View itemView) {
super(itemView);
eachitemimg = (ImageView) itemView.findViewById(R.id.imageview_eachitem);
eachitemtxt = (TextView) itemView.findViewById(R.id.textview_eachitem);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(context, "id:" + getAdapterPosition(),
Toast.LENGTH_SHORT).show();
int i=getAdapterPosition();
if (i != RecyclerView.NO_POSITION) {
mListener.onItemClick(i);
}}
});}}}
here there is full adapter code
on other activity i get intent.
in the adapter when testing Toast its completely works but on the mlistener and
setting id it does not work

found it.
just need to add
Adapter.setOnItemClickListener(Activitymain.this)
to your Mainactivity

i just changed your holder class in adapter try the below code
public class myholder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView eachitemtxt;
private ImageView eachitemimg;
public myholder(#NonNull final View itemView) {
super(itemView);
eachitemimg = (ImageView) itemView.findViewById(R.id.imageview_eachitem);
eachitemtxt = (TextView) itemView.findViewById(R.id.textview_eachitem);
itemView.setOnClickListener(this);
}
#Override
public void onClick(View v) {
int p = getAdapterPosition();
datamodel clickedItem = postlist.get(p);
Intent detailIntent = new Intent(context, Main2Activity.class);
detailIntent.putExtra(EXTRA_URL, clickedItem.getmTitle());
context.startActivity(detailIntent);
}
}

Related

How can i fix my problem with RecyclerView and OnClickAdapter?

Sorry, i have a problem, i have created ad adapter for a recyclerView to click on one of my item but it doesn't work, it is very frustrating, do you have any ideas?
I have used it in a old application and it works properly but now i don't know why it doesn't work...
Here is my adapter:
public class TecniciAdapter extends RecyclerView.Adapter<TecniciAdapter.MyViewHolder> {
private Context mContext;
private List<Utenti> tecniciList;
private OnTecniciListner onTecniciListner;
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView nome;
public TextView cognome;
public TextView stato;
public OnTecniciListner onTecniciListner;
public MyViewHolder(View view, OnTecniciListner onTecniciListner) {
super(view);
nome = view.findViewById(R.id.textNome);
cognome = view.findViewById(R.id.textCognome);
stato = view.findViewById(R.id.textCurrentState);
this.onTecniciListner = onTecniciListner;
view.setOnClickListener(this);
}
#Override
public void onClick(View v) {
onTecniciListner.onTecniciClick(getAdapterPosition());
}
}
public TecniciAdapter(Context context, ArrayList<Utenti> list, OnTecniciListner onTecniciListner) {
this.mContext = context;
this.tecniciList = list;
this.onTecniciListner = onTecniciListner;
}
#NonNull
#Override
public TecniciAdapter.MyViewHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(mContext)
.inflate(R.layout.technician_item, viewGroup, false);
return new TecniciAdapter.MyViewHolder(view, onTecniciListner);
}
#Override
public void onBindViewHolder(#NonNull MyViewHolder myViewHolder, int i) {
myViewHolder.nome.setText(tecniciList.get(i).getNome());
myViewHolder.cognome.setText(tecniciList.get(i).getCognome());
myViewHolder.stato.setText(tecniciList.get(i).getStato());
}
#Override
public int getItemCount() {
return tecniciList.size();
}
public interface OnTecniciListner{
void onTecniciClick(int position);
}
}
and this is the part in the fragment:
TecniciAdapter adapter = new TecniciAdapter(getActivity(), tecniciList, TecniciFragment.this);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(adapter);
I have also this in my fragment:
#Override
public void onTecniciClick(int position) {
Utenti tecnici = tecniciList.get(position);
Intent intent = new Intent(getActivity(), LoginActivity.class);
startActivity(intent);
}
You do not need to create an instance of OnTecniciListner in your ViewHolder class, the one in the TecniciAdapter should work just fine.
So your MyViewHolder class should look like this
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView nome;
public TextView cognome;
public TextView stato;
public MyViewHolder(View view) {
super(view);
nome = view.findViewById(R.id.textNome);
cognome = view.findViewById(R.id.textCognome);
stato = view.findViewById(R.id.textCurrentState);
view.setOnClickListener(this);
}
#Override
public void onClick(View v) {
onTecniciListner.onTecniciClick(getAdapterPosition());
}
}
in onBindViewHoldertry this :
myViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});

Recyclerview onItemClick not working (no log)

I wanted to implement an OnItemClick on the elements of my RecyclerView and i built an interface on my adapter and I am calling it on my activity, however the click isn't working and there is no errors in the log, so I'm not sure what I'm messing up. It is a Grid Recyclerview, if that affects anything.. The toast doesn't show up either.
my adapter
public class ImagesAdapter extends RecyclerView.Adapter<ImagesAdapter.ImageViewHolder> {
private Context mContext;
private List<Images> mUploads;
private OnItemClickListener mListener;
public ImagesAdapter(Context context, List<Images> uploads) {
mContext = context;
mUploads = uploads;
}
#Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.layout_view_post, parent, false);
return new ImageViewHolder(v);
}
#Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
Picasso.get().load(mUploads.get(position).getImage_url2()).fit().centerCrop().into(holder.imageView);
}
#Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public ImageView imageView;
LinearLayout view_container;
public ImageViewHolder(View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.thumbnail2);
view_container = itemView.findViewById(R.id.container2);
}
#Override
public void onClick(View v) {
if (mListener != null) {
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
mListener.onItemClick(position);
}
}
}
}
public interface OnItemClickListener {
void onItemClick(int position);
}
public void setOnItemClickListener(OnItemClickListener listener) {
mListener = listener;
}
}
My activity
public class ProfileActivity2 extends AppCompatActivity implements OnMapReadyCallback, ImagesAdapter.OnItemClickListener {
mRecyclerview = findViewById(R.id.recyclerview_insideprofile);
mRecyclerview.setLayoutManager(new GridLayoutManager(this, 2));
mRecyclerview.setHasFixedSize(true);
mAdapter = new ImagesAdapter(ProfileActivity2.this, mImages);
mRecyclerview.setAdapter(mAdapter);
mStorage = FirebaseStorage.getInstance();
mDatabaseRef = FirebaseDatabase.getInstance().getReference("Building_Images");
mAdapter.setOnItemClickListener(ProfileActivity2.this);
#Override
public void onItemClick(int position) {
Toast.makeText(ProfileActivity2.this, "TestMessage", Toast.LENGTH_SHORT).show();
Images selectedItem = mImages.get(position);
final String image_url = selectedItem.getImage_url2();
Intent mainIntent = new Intent(ProfileActivity2.this, FullScreenImageActivity.class);
mainIntent.putExtra("b_image_url", image_url);
startActivity(mainIntent);
}
You forgot to add itemView.setOnClickListener in your viewholder, you have to add:
public ImageViewHolder(View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.layout);
itemView.setOnClickListener(this);

How to get image from recyclerview position clicked data and set it into another imageview?

I have an app which contains recyclerview with imageview and text.When I click on item based on position that is imageview i want image of that image view and set it to another Imageview.To do this I have made interface and implements its method in Activity but need to know that how do i do that
Adapter code:
public interface OnItemClicked {
void onItemClicked(int position);
}
public AvatarListAdapter(Context context, int[] arrayList) {
this.mContext = context;
this.dataModel = arrayList;
}
#Override
public AvatarListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.avatar_items, parent, false);
return new AvatarListAdapter.ViewHolder(view);
}
#Override
public void onBindViewHolder(AvatarListAdapter.ViewHolder holder, final int position) {
holder.mAvatarImage.setImageResource(dataModel[position]);
holder.mAvatarImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onClick.onItemClicked(position);
}
});
}
public void setOnClick(OnItemClicked onClick) {
this.onClick = onClick;
}
#Override
public int getItemCount() {
return dataModel.length;
}
public class ViewHolder extends RecyclerView.ViewHolder {
private CircleImageView mAvatarImage;
public ViewHolder(View itemView) {
super(itemView);
mAvatarImage = itemView.findViewById(R.id.img_avatar);
}
}
}
Activity code:
private void initializeActions() {
int numberOfColumns = 3;
mAvatarImages.setLayoutManager(new GridLayoutManager(AvatarProfileImage.this, numberOfColumns));
mAdapter = new AvatarListAdapter(AvatarProfileImage.this, avatar);
mAvatarImages.setAdapter(mAdapter);
mAdapter.setOnClick(this);
}
#Override
public void onItemClicked(int position) {
String pos = "You clicked at position " + position;
Toast.makeText(getApplicationContext(), "You clicked position" + pos, Toast.LENGTH_LONG).show();
mAvatarImages.setBackgroundResource(avatar[position]);
}
You can get data by position on OnClick().As you are using local drawable for image resource, One way to do is Modify your viewHolder as follows.This is just a one way you can also use ViewTag.
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private Circle mAvatarImage;
public ViewHolder(View itemView) {
super(itemView);
mAvatarImage = itemView.findViewById(R.id.img_avatar);
mAvatarImage.setOnClickListener(this);
}
#Override
public void onClick(View v) {
int postion =getAdapterPosition();
int image =arrayList[postion];
// Use this image to forward
}
}
Remove OnClick from onBindViewHolder.
Implement RecycleView onClick() method and get specified data while onclick position.have look
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private Circle mAvatarImage;
public ViewHolder(View itemView) {
super(itemView);
mAvatarImage = itemView.findViewById(R.id.img_avatar);
mAvatarImage.setOnClickListener(this);
}
#Override
public void onClick(View v) {
int position=arrayList[getAdapterPosition()];
String imagepath = arraylist.get(position).getImagePath
//you can use imagepath anywhere you want either be put in bundle or intent call
}
}
Adapter code should look like this
private final OnItemClickListener listenerOnItemClick;
public interface OnItemClickListener {
void onItemClick(int position); }
public AvatarListAdapter(Context context, int[] arrayList, OnItemClickListener listenerOnItemClick) {
this.mContext = context;
this.dataModel = arrayList;
this.listenerOnItemClick=listenerOnItemClick;
}
#Override
public AvatarListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.avatar_items, parent, false);
return new AvatarListAdapter.ViewHolder(view); }
#Override
public void onBindViewHolder(AvatarListAdapter.ViewHolder holder, final int position) {
holder.mAvatarImage.setImageResource(dataModel[position]);
holder.mAvatarImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onClick.onItemClicked(position);
}
}); }
public void setOnClick(OnItemClicked onClick) {
this.onClick = onClick; }
#Override
public int getItemCount() {
return dataModel.length; }
public class ViewHolder extends RecyclerView.ViewHolder {
private CircleImageView mAvatarImage;
public ViewHolder(View itemView) {
super(itemView);
mAvatarImage = itemView.findViewById(R.id.img_avatar);
} }
Activity Code
AvatarListAdapter.OnItemClickListener onItemClickListener = new AvatarListAdapter.OnItemClickListener() {
#Override
public void onItemClick(int position) {
//change your Image here
String pos = "You clicked at position " + position;
Toast.makeText(getApplicationContext(), "You clicked position" + pos, Toast.LENGTH_LONG).show();
mAvatarImages.setBackgroundResource(avatar[position]);
}
};
private void initializeActions() {
int numberOfColumns = 3;
mAvatarImages.setLayoutManager(new GridLayoutManager(AvatarProfileImage.this, numberOfColumns));
mAdapter = new AvatarListAdapter(AvatarProfileImage.this, avatar,onItemClickListener );
mAvatarImages.setAdapter(mAdapter);
mAdapter.setOnClick(this);
}

RecyclerView OnItemclick not working properly

I have a recycler view and I am implementing OnClicklistener inside it. Basically , I have an adapter class called actressadapter and a viewholder class MyViewHolder.I am implementing OnClickListener inside viewholder class to initiate another activity via intent method. My basic data is inside a class called actress which has three variables name,country(both String) and an Id(UUID). I am providing this data that is of actresses to my adapter.Next activity is just displaying the name of actress like abc ,def etc that it retrieves . The fault is that it shows name of only one actress after clicking. For instance if it shows abc ,then for each click it will show abc.Don't know why is this happening because as per code I am passing actressname as an extra .
public class actressadapter extends RecyclerView.Adapter <actressadapter.MyViewHolder> {
private List<Actress>al;
private Actress actress,mActress;
public static final String str="shivam.panwar.actressdetails.actressadapter.str";
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView naam, desh;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
naam = (TextView) view.findViewById(R.id.name);
desh= (TextView) view.findViewById(R.id.country);
}
#Override
public void onClick(View v) {
Toast.makeText(v.getContext(),"Clicked",Toast.LENGTH_SHORT).show();
Intent intent=new Intent(v.getContext(),Actressview.class);
intent.putExtra(str,actress.getName());
v.getContext().startActivity(intent);
}
public void bindactress(Actress mActress) {
naam.setText(mActress.getName());
desh.setText(mActress.getCountry());
}
}
public actressadapter(List<Actress> al) {
this.al = al;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.actress_list_row, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
actress =al.get(position);
holder.bindactress(actress);
}
#Override
public int getItemCount() {
return al.size();
}
}
If required any further assist about code please comment.
try this way hope it works...
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
actress =al.get(position);
holder.bindactress(actress);
holder.naam.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context,holder.naam.getText().toString(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context,Actressview.class);
intent.putExtra(str,holder.naam.getText().toString());
context.startActivity(intent);
}
});
}
The best way to use the method getLayoutPosition() of adapter class to get the selected item(position).
You have to update your code for better result. Replace your existing code with that.
public class actressadapter extends RecyclerView.Adapter <actressadapter.MyViewHolder> {
private List<Actress>al;
private Actress actress,mActress;
private int itemPosition; // change
public static final String str="shivam.panwar.actressdetails.actressadapter.str";
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView naam, desh;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
naam = (TextView) view.findViewById(R.id.name);
desh= (TextView) view.findViewById(R.id.country);
}
#Override
public void onClick(View v) {
itemPosition = getLayoutPosition(); // change
Toast.makeText(v.getContext(),"Clicked",Toast.LENGTH_SHORT).show();
Intent intent=new Intent(v.getContext(),Actressview.class);
intent.putExtra(str,al.get(itemPosition).getName()); // change
v.getContext().startActivity(intent);
}
public void bindactress(Actress mActress) {
naam.setText(mActress.getName());
desh.setText(mActress.getCountry());
}
}
public actressadapter(List<Actress> al) {
this.al = al;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.actress_list_row, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
actress =al.get(position);
holder.bindactress(actress);
}
#Override
public int getItemCount() {
return al.size();
}
}
Hope it will work..
your issue is that you made actress a variable of the Adapte, and it should be of the Holder.
To fix it:
Delete the line:
private Actress actress,mActress;
Change the onBindViewHolder method to:
holder.bindactress(al.get(position))
And make replace your holder class with that:
// holder HAVE TO be static. It's WRONG not doing it static
public static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView naam, desh;
Actress actress;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
naam = (TextView) view.findViewById(R.id.name);
desh= (TextView) view.findViewById(R.id.country);
}
#Override
public void onClick(View v) {
Toast.makeText(v.getContext(),"Clicked",Toast.LENGTH_SHORT).show();
Intent intent=new Intent(v.getContext(),Actressview.class);
intent.putExtra(str,actress.getName());
v.getContext().startActivity(intent);
}
public void bindactress(Actress mActress) {
this.actress = mActress;
naam.setText(mActress.getName());
desh.setText(mActress.getCountry());
}
}

Getting RecyclerView.Adapter List from ViewHolder

Is any way to transfer the current list of items to a new Activity using OnClickListener of ViewHolder? Or any other way?
public class RVAdapter extends RecyclerView.Adapter<RVAdapter.EventsViewHolder> {
List<Event> events; //get this List
RVAdapter(List<Event> events) {
this.events = events;
}
public static class EventsViewHolder extends RecyclerView.ViewHolder {
TextView date;
TextView text;
ImageView photo;
EventsViewHolder(final View itemView) {
super(itemView);
date = (TextView) itemView.findViewById(R.id.date);
text = (TextView) itemView.findViewById(R.id.text);
photo = (ImageView) itemView.findViewById(R.id.photo);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Context context = v.getContext();
SendObject sendObject = new SendObject(setList); //and transfer it here
Intent intent = new Intent(context, ReadEvent.class);
Bundle bundle = new Bundle();
bundle.putSerializable("events", sendObject);
bundle.putInt("pos", getAdapterPosition());
bundle.putString("test", "test");
intent.putExtras(bundle);
context.startActivity(intent);
}
});
}
}
Solution 1: Create method in ViewHolder in which you pass your list
Solution 2: Define your ViewHolder as not static class and pass your list
Another approach:
// Solution 1:
public class EventsViewHolder extends RecyclerView.ViewHolder {
EventsViewHolder(final View itemView) {
super(itemView);
}
public void bind(List<Event> events) {
...
SendObject sendObject = new SendObject(events); //and transfer it here
...
}
}
// Solution 2:
public class EventsViewHolder extends RecyclerView.ViewHolder {
EventsViewHolder(final View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
SendObject sendObject = new SendObject(events); //and transfer it here
}
});
}
}
Adapter Class.
public ServicesHomeAdapter(Context context, ArrayList<HomeScreenData> homeScreenDataArrayList,OnItemClickedListener listener) {
this.context=context;
this.homeScreenDataArrayList=homeScreenDataArrayList;
this.listener=listener;
}
#Override
public ServicesHomeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_service,parent,false);
ViewHolder viewHolder=new ViewHolder(view);
return viewHolder;
}
#Override
public void onBindViewHolder(final ServicesHomeAdapter.ViewHolder holder, int position) {
final HomeScreenData homeScreenData = homeScreenDataArrayList.get(position);
}
#Override
public int getItemCount()
{
return (null!=homeScreenDataArrayList?homeScreenDataArrayList.size():0);
}
public class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView ivSection;
protected TextView txImageName;
public ViewHolder(View itemView)
{
super(itemView);
this.ivSection= (ImageView) itemView.findViewById(R.id.ivcard);
this.txImageName= (TextView) itemView.findViewById(R.id.txtimgname);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
listener.onItemClicked(getAdapterPosition());
}
});
}
}
public interface OnItemClickedListener{
void onItemClicked(int position);
}
}
Implement the interface in your Activity.
#Override
public void onItemClicked(int position) {
Intent intent = new Intent(getActivity(), A.class);
Pojo Class pojo = arrayList.get(position);
intent.putExtra(TAG, pojo);
startActivity(intent);
}`
Your Pojo should parseable or serialised but now android recommends to implement parseable then you can pass any Pojo through intent, How you can make your class parseable check this link.
https://developer.android.com/reference/android/os/Parcelable.html
intent.putExtra(key, Serializable/Parcelable) and then in second activity getParcelableExtra(key)/getSerializableExtra(key)
I had a Serializable object already:
public class SendObject implements Serializable{
private List<Event> events;
public SendObject(List<Event> events) {
this.events = events;
}
public List<Event> getEvents() {
return events;
}
}
The main problem was to receive current Adapter List. The problem is solved by using Singleton. The solution was simple.
public class RVAdapter extends RecyclerView.Adapter {
private static RVAdapter rvAdapter;
private List<Event> events;
public RVAdapter() {
}
public static RVAdapter getInstance() {
if (rvAdapter==null) {
rvAdapter = new RVAdapter();
}
return rvAdapter;
}
public void setList(List<Event> events) {
this.events = events;
}
public static class EventsViewHolder extends RecyclerView.ViewHolder {
TextView date;
TextView text;
ImageView photo;
EventsViewHolder(final View itemView) {
super(itemView);
date = (TextView) itemView.findViewById(R.id.date);
text = (TextView) itemView.findViewById(R.id.text);
photo = (ImageView) itemView.findViewById(R.id.photo);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Context context = v.getContext();
SendObject sendObject = null;
sendObject = new SendObject(RVAdapter.getInstance().events); //current List
Intent intent = new Intent(context, ReadEvent.class);
Bundle bundle = new Bundle();
bundle.putSerializable("events", sendObject);
bundle.putInt("pos", getAdapterPosition());
intent.putExtras(bundle);
context.startActivity(intent);
}
});
}
}
Anyway, thanks for your responses!

Categories

Resources