Home » Android » android – overridePendingTransition on gridview adapter

android – overridePendingTransition on gridview adapter

Posted by: admin June 15, 2020 Leave a comment


How can I insert overridePendingTransition on a GridView `Adapter? In this way don’t work, without transition startactivity work perfectly

bt.setOnLongClickListener(new OnLongClickListener(){
                public boolean onLongClick(View v) {
                        final String selectedPad = Drum.pads[position];
                        Intent modPad = new Intent(v.getContext(), ModifyPad.class);
                        modPad.putExtra("pad", selectedPad);
                        overridePendingTransition(R.anim.exit_slid_in, R.anim.exit_slid_out);
                    return false;

I’ve read this post:
android start Activity in adapter (transition animiation direction problem), and comments related, but I don’t know how pass the Activity in the Adapter. Any help?

How to&Answers:

Context is the Base Object of Activity ( see: What is the difference between Activity and Context? ),
so I used following:

Activity activity = (Activity) mContext;
activity.overridePendingTransition(R.anim.act_start_in_from_right, R.anim.act_start_out_to_left);

Refers to: Getting activity from context in android