您好我有一个应用程序,我可以触摸滚动浏览多个屏幕,如
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); } }); } }
解决方法
您可以参考apidemos目录中的
example,它使用overridePendingTransition来显示自定义动画.还有一个与此主题相关的帖子:
Can I change the Android startActivity() transition animation?