8

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

bt.setOnLongClickListener(new OnLongClickListener(){
                @Override
                public boolean onLongClick(View v) {
                        final String selectedPad = Drum.pads[position];
                        Intent modPad = new Intent(v.getContext(), ModifyPad.class);
                        modPad.putExtra("pad", selectedPad);
                        context.startActivity(modPad);
                        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?

Community
  • 1
  • 1
kosma822
  • 183
  • 1
  • 2
  • 7

1 Answers1

23

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.startActivity(repinIntent);
activity.overridePendingTransition(R.anim.act_start_in_from_right, R.anim.act_start_out_to_left);

Refers to: Getting activity from context in android

Community
  • 1
  • 1
Ranger Way
  • 539
  • 6
  • 11