[/code]"> [/code]"> [/code]">
When I click ImageView, it go to GridView activity with position. When I click others area inside a cardview, it go to ItemDetailActivtiy with position. How to do one line or less than coding when click.
[code]public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView tv_restaurant_name, tv_restaurant_address, tv_restaurant_phone; ImageView imgview; public ViewHolder(View itemView) { super(itemView); tv_restaurant_name = (TextView) itemView.findViewById(R.id.tv_restaurant_name); tv_restaurant_address = (TextView) itemView.findViewById(R.id.tv_restaurant_address); tv_restaurant_phone = (TextView) itemView.findViewById(R.id.tv_restaurant_phone); imgview = (ImageView) itemView.findViewById(R.id.imgview); tv_restaurant_name.setOnClickListener(this); tv_restaurant_address.setOnClickListener(this); tv_restaurant_phone.setOnClickListener(this); imgview.setOnClickListener(this); } @Override public void onClick(View v) { int position = getAdapterPosition(); if (v.getId() == imgview.getId()) { Intent intent = new Intent(context, GridView.class); Bundle bundle = new Bundle(); bundle.putInt("ID", Integer.valueOf(mRestaurantList.get(position).getRestaurantId())); intent.putExtras(bundle); context.startActivity(intent); } else { context.startActivity(new Intent(context, ItemDetailActivtiy.class)); } } }[/code]


JLCPCB – Prototype 10 PCBs for $2 (For Any Color)

China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir