简单的Android页面跳转
来源:互联网 发布:wan端口断开 编辑:程序博客网 时间:2024/05/15 17:14
/**
*
* @author Administrator
*BMI计算器
*重点:数据传递,界面切换菜单设置
*单键按键监听(XML中设置)
*/
public class MainActivity extends Activity {
EditText height,wei;
Button comp,clear;
double heightDouble,weiDouble,bmi;
String heightString,weiString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
height=(EditText)findViewById(R.id.height);
wei=(EditText)findViewById(R.id.wei);
comp=(Button)findViewById(R.id.comp);
clear=(Button)findViewById(R.id.clear);
}
public void clear3(View v){
height.setText("");
wei.setText("");
}
public void comp(View v){
heightString=height.getText().toString();
weiString=wei.getText().toString();
if(heightString.equals("")||weiString.equals(""))
{
Toast.makeText(MainActivity.this, "身高或体重不能为空",Toast.LENGTH_LONG).show();
}
else{
heightDouble = Double.parseDouble(height.getText().toString());
weiDouble = Double.parseDouble(wei.getText().toString());
bmi=weiDouble/(heightDouble*heightDouble);
Intent intent=new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("bmi",bmi );
intent.putExtra("height", heightDouble);
startActivity(intent);
finish();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
// return super.onOptionsItemSelected(item);
super.onOptionsItemSelected(item);
switch(item.getItemId())
{
case R.id.close:
System.exit(0);
break;
}
return true;
}
}
*
* @author Administrator
*BMI计算器
*重点:数据传递,界面切换菜单设置
*单键按键监听(XML中设置)
*/
public class MainActivity extends Activity {
EditText height,wei;
Button comp,clear;
double heightDouble,weiDouble,bmi;
String heightString,weiString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
height=(EditText)findViewById(R.id.height);
wei=(EditText)findViewById(R.id.wei);
comp=(Button)findViewById(R.id.comp);
clear=(Button)findViewById(R.id.clear);
}
public void clear3(View v){
height.setText("");
wei.setText("");
}
public void comp(View v){
heightString=height.getText().toString();
weiString=wei.getText().toString();
if(heightString.equals("")||weiString.equals(""))
{
Toast.makeText(MainActivity.this, "身高或体重不能为空",Toast.LENGTH_LONG).show();
}
else{
heightDouble = Double.parseDouble(height.getText().toString());
weiDouble = Double.parseDouble(wei.getText().toString());
bmi=weiDouble/(heightDouble*heightDouble);
Intent intent=new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("bmi",bmi );
intent.putExtra("height", heightDouble);
startActivity(intent);
finish();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
// return super.onOptionsItemSelected(item);
super.onOptionsItemSelected(item);
switch(item.getItemId())
{
case R.id.close:
System.exit(0);
break;
}
return true;
}
}
0 0
- 简单的Android页面跳转
- android 的页面跳转
- Android的页面跳转
- Android的页面跳转
- Android页面最简单的跳转出现的问题
- 简单的页面跳转代码
- 简单的页面跳转效果
- android页面跳转的实现
- Android页面跳转的方法
- android 页面的自动跳转
- Android页面的跳转方式
- Android开发-UI控件:实现登陆页面并跳转和简单的注册页面
- 简单的页面自动跳转 倒数计时
- 最简单的页面自动刷新&跳转
- 基于jQuery简单的定时跳转页面
- 一个简单的jquery页面内跳转
- 关于html简单页面跳转的问题
- QT实现简单验证的页面跳转
- 数字信号处理公式变程序(四)——巴特沃斯滤波器(上)
- STM32W108无线射频模块中断控制器(NVIC)
- OC中的类和对象
- Squid正向代理
- 在主机屋的虚拟主机上安装Discuz_X3.2
- 简单的Android页面跳转
- 如何查看errno 错误代码
- STM32W108无线射频模块串行通信接口
- CSRF
- Squid正向代理的身份验证
- 类模板与友元函数链接问题
- Binder学习一——基础数据结构
- 关于C指针
- CSRF 攻击的应对之道