无法关闭过渡 [英] Can't turn transitions off
问题描述
我试图在我的一些过渡之间没有动画.我有一点代码:
I'm trying to have no animation between some of my transitions. I have this bit bit of code:
TextView pulse = (TextView) findViewById(R.id.pulseText);
pulse.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(), Pulse.class);
startActivityForResult(myIntent, 0);
finish();
}
});
为了停止动画,我在开始活动后添加了这个:
So to stop animation, I added this after starting the activity:
overridePendingTransition(0, 0);
但这导致了一个错误,提示方法 overridePendingTransition(int, int) 未定义为类型 new View.OnClickListener(){}".然后我尝试添加
But that caused an error saying, "The method overridePendingTransition(int, int) is undefined for the type new View.OnClickListener(){}". So then I tried adding
`myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ACTION);`
在开始活动之前,但这也不起作用.有什么想法吗?
before starting the activity, but that didn't work either. Any ideas?
推荐答案
尝试编写:
ActivityClassName.this.overridePendingTransition(0, 0);
其中 ActivityClassName
是您的活动类的名称
where ActivityClassName
is the name of your activity class
从 Pulse.class 开始 Board.class,而不是写:
To start Board.class from Pulse.class, instead of writing:
Intent myIntent = new Intent(v.getContext(), Pulse.class);
应该是:
Intent myIntent = new Intent(v.getContext(), Board.class);
这篇关于无法关闭过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!