android的Activity转换
原文地址:http://blog.sina.com.cn/s/blog_694448320100lw0s.html
演示代码如下:
public class OneActivity extends Activity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button nextButton = (Button)findViewById(R.id.next);
nextButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
nextLayout();
}
});
}
public void nextLayout(){
setContentView(R.layout.two);
Button upButton = (Button)findViewById(R.id.up);
upButton.setOnClickListener(new View.OnClickListner(){
public void onClick(View v){
upLayout();
}
});
}
public void upLayout(){
setContentView(R.layout.main);
Button nextButton = (Button)findById(R.id.next);
nextButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
nextLayout();
}
});
}
}