gridview适配器上的overridePendingTransition

时间:2013-03-22 03:02:31

标签: android override adapter transition baseadapter

如何在overridePendingTransition`适配器上插入GridView?这种方式不起作用,没有转换启动功能完美的工作

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;
                }
            });

我看过这篇文章: android start Activity in adapter (transition animiation direction problem),评论相关,但我不知道如何通过Activity中的Adapter。有什么帮助吗?

1 个答案:

答案 0 :(得分:23)

Context是Activity的基础对象(参见:What is the difference between Activity and Context?), 所以我使用了以下内容:

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

指:Getting activity from context in android