gpt4 book ai didi

android - gridview 适配器上的 overridePendingTransition

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:51:22 25 4
gpt4 key购买 nike

如何在 GridView `Adapter 上插入 overridePendingTransition?这种方式行不通,没有transition startactivity完美运行

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) , 和评论相关,但我不知道如何在 Adapter 中传递 Activity。有帮助吗?

最佳答案

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

关于android - gridview 适配器上的 overridePendingTransition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15561991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com