Can't turn transitions off

戏子无情 提交于 2019-12-23 03:39:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!