Android编程8:页面切换测试
来源:互联网 发布:linux怎么退出root用户 编辑:程序博客网 时间:2024/05/16 07:41
Android编程8:页面切换测试
本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明.
软件平台:win7 + eclipse + sdk
设计思路:
两个页面:mian和ok,每个页面上有一个按键,点击则可以互相切换
源代码:
main.xml源代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /><Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一页面 "></Button></LinearLayout>
ok.xml源代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上一页面 " android:id="@+id/button1"></Button></LinearLayout>
makechoice源代码:
package com.makechoice;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Button;public class makechoice extends Activity{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { jump2ok(); } }); } //跳到ok页面 public void jump2ok() { setContentView(R.layout.ok); //当有按键按下跳到main页面 Button btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { jump2main(); } }); } //跳到main页面 public void jump2main() { setContentView(R.layout.main); //当有按键按下跳到ok页面 Button btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { jump2ok(); } }); }}
运行效果图:
注意:
类R中存放的ID号为当前页面的ID号,所以findViewById函数捕获的控件也为当前页面的控件
- Android编程8:页面切换测试
- android(8) ViewPager页面滑动切换
- android页面切换
- android页面切换动画
- android页面切换
- android 页面切换
- Android通过setContentView切换页面示例(华为U9200下测试,最短切换耗时2ms,稳定在6-8ms)
- qt5 mouseless 多子页面切换测试
- android 页面切换动画效果
- android 页面切换动画效果
- android 切换页面 代码示例
- Android左右滑动切换页面
- Android 页面自动切换实现
- Android 滑动切换页面-ViewFlipper
- android多页面滑动切换
- Android 页面左右滑动切换
- 【Android开发】页面切换动画
- Android手指滑动切换页面
- android phone 模块分析
- 什么是闭包,我的理解 (转载)
- 网络数据包捕获与发送的多重实现(转载)
- 用例建模 组件和服务建模 性能建模 概念
- Hashcode总结
- Android编程8:页面切换测试
- 更新表的数据
- iPhone开发中,动态调用类和方法
- Eclipse上的HTML/JSP/XML编辑器插件Eclipse HTML Editor
- NEC单片机内存数据存储形式
- 关于u cos 中延时函数OSTimeDly和任务通信***pend()函数对任务的影响分析
- 反编译实例2:补充3
- 输入子系统简单(按键)测试
- 插件21:把URL相对地址转换为绝对地址