I've created an intent object along with Bundle when a CardView is clicked and then I start the Activity. How do I declare overridePendingTransition inside it? Code is given belew :
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
holder.textView.setText(strings[position]);
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(holder.itemView.getContext(),SecondActivity.class);
Bundle bundle = new Bundle();
bundle.putString("list",strings[position]);
intent.putExtras(bundle);
holder.itemView.getContext().startActivity(intent);
//overridePendingTransition(R.anim.abc_fade_in,R.anim.abc_fade_out);
}
});
}
You must pass an
Activityto yourRecyclerView.Adapterclass when declaring it like :First of all in your Adapter's constructor add
Activityfield :Then add this line in your
Activity:Activity thisActivity=(Activity)this;Then in your
Activitydeclare your adapter like :And finally you can use this
Activityin your adapter for transition like :