ITeye博客

android的Activity转换

javaxhw · 2010-10-28 13:40 · android · 移动开发 · Markdown

原文地址: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(); } });

} }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。