我正在尝试使用按钮启动新活动,但新活动仅显示约五秒钟并返回。这就是我的代码:
public class Splash extends Activity implements OnClickListener{
Button next, Previous, menu;
ViewFlipper vf;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
next = (Button)findViewById(R.id.Button01);
menu = (Button)findViewById(R.id.menu);
Previous = (Button)findViewById(R.id.Button02);
vf = (ViewFlipper)findViewById(R.id.ViewFlipper1);
next.setOnClickListener((OnClickListener) this);
Previous.setOnClickListener((OnClickListener) this);
menu.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Splash.this, Menu.class);
startActivity(intent);
}
});
}
public void onClick(View v) {
// TODO Auto-generated method stub
if(v==next){
vf.showNext();
}
if(v==Previous){
vf.showPrevious();
}
}
}
这是Menu活动的代码。但它不完整:
public class Menu extends AFFIRMATION implements OnClickListener{
Button about;
Button contact;
Button products;
Button cards;
//@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
about = (Button)findViewById(R.id.button1);
contact = (Button)findViewById(R.id.button2);
products = (Button)findViewById(R.id.button3);
cards = (Button)findViewById(R.id.button4);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:0)
查看定义ViewFlipper的xml。
查看是否已正确设置android:autoStart
和android:flipInterval
。
答案 1 :(得分:0)
have u Declare the new Activity in your manifest.xml.
you have to write this in between....
<application> ........
<activity android:name=".Menu"
android:label="xyz"/>
</application>