Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overridePendingTransition on gridview adapter

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?

like image 987
kosma822 Avatar asked Mar 22 '13 03:03

kosma822


1 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.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

like image 193
Ranger Way Avatar answered Oct 18 '22 22:10

Ranger Way