简单的Android页面跳转
2017-09-05 00:00
295 查看
/**
*
*
@author Administrator
*BMI计算器
*重点:数据传递,界面切换菜单设置
*单键按键监听(XML中设置)
*/
*
*
@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; } }
相关文章推荐
- Android之简单页面跳转
- Android开发-UI控件:实现登陆页面并跳转和简单的注册页面
- Android小技巧 如此简单就跳转了页面
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- Android页面最简单的跳转出现的问题
- Android项目实践之菜鸟养成 (三)Android简单页面跳转
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- 移动开发 - Android - 实现两个页面(Activity)的简单跳转(Intent)
- 【Android初学者】超简单的注册页面,填写完整信息实现 跳转 和 传参
- Android笔记-4-实现登陆页面并跳转和简单的注册页面
- Android 页面跳转和数据传递
- Android 倒计时跳转页面
- android 学习随笔十四(页面跳转与数据传递)
- Android安装应用和跳转应用简单记录
- 从android应用程序跳转到系统的各个设置页面
- android基础页面跳转
- iOS超简单页面跳转传值
- 关于在Android中Activity页面跳转的方法
- android 点击跳转应用市场评分页面