问题
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);
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?
回答1:
Try writing:
ActivityClassName.this.overridePendingTransition(0, 0);
where ActivityClassName is the name of your activity class
EDIT:
To start Board.class from Pulse.class, instead of writing:
Intent myIntent = new Intent(v.getContext(), Pulse.class);
It should be:
Intent myIntent = new Intent(v.getContext(), Board.class);
回答2:
You must go to your class Pulse
Add to onCreate(Bundle) the line:
overridePendingTransition(0, 0);
and probably you want to add this line to the onCreate() of all your activities
来源:https://stackoverflow.com/questions/6950215/cant-turn-transitions-off