[英]The method overridePendingTransition(int, int) is undefined for the type new View.OnClickListener(){}
I tried to add animation on start activity intent and I got this error. 我尝试在开始活动意图上添加动画,但出现此错误。 It's the first time I've seen something like this, I looked up on google and SO but I was unable to find anything that would help me solve this issue.
这是我第一次看到这样的内容,我在google和SO上进行了查找,但找不到任何能帮助我解决此问题的内容。 So how can I fix this?
那么我该如何解决呢? Whats wrong with my code?
我的代码有什么问题?
holder.transfer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@SuppressWarnings("unused")
int clickedposition = (Integer) v.getTag();
Intent iv = new Intent(context,
MenuActivity.class);
if (iv != null) {
iv.putExtra("NAME", ringNames[position]);
int [] res = songPos;
iv.putExtra("PATH", res[position]);
iv.putExtra("FILE", ringNames[position]+".mp3");
((Activity) context).startActivity(iv);
overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
}
try
{
CentralActivity.playing = Boolean.valueOf(false);
CentralActivity.mp.stop();
CentralActivity.mp.release();
return;
}
catch (Exception localException)
{
}
}
});
I get error The method overridePendingTransition(int, int) is undefined for the type new View.OnClickListener(){} thanks 我收到错误对于新View.OnClickListener(){}类型,未定义方法overridePendingTransition(int,int),谢谢
Replase your: 更换您的:
overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
To: 至:
((Activity) context).overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
You need to call methdod overridePendingTransition
from activity, but you do it in OnClickListener
. 你需要调用methdod
overridePendingTransition
从一个活动,但你在做OnClickListener
。
try this: 尝试这个:
Intent iv = new Intent(CurrentActivity.this
MenuActivity.class);
if (iv != null) {
iv.putExtra("NAME", ringNames[position]);
int [] res = songPos;
iv.putExtra("PATH", res[position]);
iv.putExtra("FILE", ringNames[position]+".mp3");
startActivity(iv);
overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.