如何在更改活动时更改默认动画?

时间:2011-02-17 09:10:46

标签: android animation button android-activity homescreen

您好我有一个应用程序可以触摸滚动浏览多个屏幕,例如Android Homescreen应用程序。

我现在设法在每个页面上添加一个按钮,从此更改为新活动,但滚动从左到右,我希望它在单击按钮时向下滚动,但我无法弄清楚如何这样做。

(这可能是一个非常棒的问题 - 抱歉。)

这是我的main.java文件

public class main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button onebutton = (Button)findViewById(R.id.soundsone);
        onebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series1button.class);
        startActivity(i);

    }
});


        Button twobutton = (Button)findViewById(R.id.soundstwo);
        twobutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series2button.class);
        startActivity(i);

    }
});  
        Button threebutton = (Button)findViewById(R.id.soundsthree);
        threebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series3button.class);
        startActivity(i);

    }
});        Button fourbutton = (Button)findViewById(R.id.soundsfour);
        fourbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series4button.class);
        startActivity(i);

    }
});        Button fivebutton = (Button)findViewById(R.id.soundsfive);
        fivebutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series5button.class);
        startActivity(i);

    }
});        Button sixbutton = (Button)findViewById(R.id.soundssix);
        sixbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series6button.class);
        startActivity(i);

    }
});        Button sevenbutton = (Button)findViewById(R.id.soundsseven);
        sevenbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series7button.class);
        startActivity(i);

    }
});        Button eightbutton = (Button)findViewById(R.id.soundseight);
        eightbutton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Intent i = new Intent(main.this, series8button.class);
        startActivity(i);

    }
});
    }
}

3 个答案:

答案 0 :(得分:10)

您可以参考apidemos目录中的example,该目录使用overridePendingTransition来显示自定义动画。另外一篇与此主题相关的帖子:Can I change the Android startActivity() transition animation?

答案 1 :(得分:0)

您可以使用Android主题API查看我的答案How to override the enter activity animation if it is stated by launcher

答案 2 :(得分:0)

这是一个很好的样本。它伟大而顺利。我试过。答案之一:Activity transition in Android

相关问题