为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上

2017-10-06 9页 doc 27KB 19阅读

用户头像

is_260251

暂无简介

举报
Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上 Android时间单位换算小程序运行时总是出现异常,但又找不出哪里错了,麻烦哪位高人指点一下。 这是一个转换时间单位的小程序,如果不加if判断语句的话,timeClearButton就可以正常使用,但如果加上一条判断语句,程序可以正常换算时间,但使用timeClearButton时程序就会被强行关闭,如果加两条判断语句,程序只能执行第一个判断语句要做的事情,若使用第二个判断,程序会被强行关闭~下面是程序代码: Java code ...
Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上
Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上 Android时间单位换算小程序运行时总是出现异常,但又找不出哪里错了,麻烦哪位高人指点一下。 这是一个转换时间单位的小程序,如果不加if判断语句的话,timeClearButton就可以正常使用,但如果加上一条判断语句,程序可以正常换算时间,但使用timeClearButton时程序就会被强行关闭,如果加两条判断语句,程序只能执行第一个判断语句要做的事情,若使用第二个判断,程序会被强行关闭~下面是程序代码: Java code package lygtc.ruanjian.liuxiuxiu02; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class timeActivity extends Activity implements OnClickListener{ private EditText centuryText; //世纪文本框 private EditText yearText; //年文本框 private EditText monthText; //月文本框 private EditText weekText; //星期文本框 private EditText dayText; //日文本框 private EditText hourText; //小时文本框 private EditText minuteText; //分钟文本框 private EditText secondText; //秒文本框 private Button centuryButton; //世纪按钮 private Button yearButton; //年按钮 private Button monthButton; //月按钮 private Button weekButton; //星期按钮 private Button dayButton; //日按钮 private Button hourButton; //小时按钮 private Button minuteButton; //分钟按钮 private Button secondButton; //秒按钮 private EditText timeResultText; //换算结果文本框 private Button timeClearButton; //清空全部内容 private Button backButton; //返回主菜单 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.time); centuryText = (EditText)findViewById(R.id.centuryText); yearText = (EditText)findViewById(R.id.yearText); monthText = (EditText)findViewById(R.id.monthText); weekText = (EditText)findViewById(R.id.weekText); dayText = (EditText)findViewById(R.id.dayText); hourText = (EditText)findViewById(R.id.hourText); minuteText = (EditText)findViewById(R.id.minuteText); secondText = (EditText)findViewById(R.id.secondText); timeResultText = (EditText)findViewById(R.id.timeResultText); centuryButton = (Button)findViewById(R.id.centuryButton); centuryButton.setOnClickListener(this); yearButton = (Button)findViewById(R.id.yearButton); yearButton.setOnClickListener(this); monthButton = (Button)findViewById(R.id.monthButton); monthButton.setOnClickListener(this); weekButton = (Button)findViewById(R.id.weekButton); weekButton.setOnClickListener(this); dayButton = (Button)findViewById(R.id.dayButton); dayButton.setOnClickListener(this); hourButton = (Button)findViewById(R.id.hourButton); hourButton.setOnClickListener(this); minuteButton = (Button)findViewById(R.id.minuteButton); minuteButton.setOnClickListener(this); secondButton = (Button)findViewById(R.id.secondButton); secondButton.setOnClickListener(this); backButton = (Button)findViewById(R.id.backButton); backButton.setOnClickListener(this); timeClearButton = (Button)findViewById(R.id.timeClearButton); timeClearButton.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub int id = v.getId(); switch(id){ case R.id.backButton:{ Intent backIntent = new Intent(this,Liuxiuxiu02Activity.class); startActivity(backIntent); break; } case R.id.timeClearButton:{ centuryText.setText( ); yearText.setText( ); monthText.setText( ); weekText.setText( ); dayText.setText( ); hourText.setText( ); minuteText.setText( ); secondText.setText( ); timeResultText.setText( ); break; } } if(centuryText.getText().toString() != null){ //第一个判断语句 double Century = Double.parseDouble(centuryText.getText().toString()); yearText.setText( ); monthText.setText( ); weekText.setText( ); dayText.setText( ); hourText.setText( ); minuteText.setText( ); secondText.setText( ); switch(id){ case R.id.centuryButton:{ double century = Century*1; timeResultText.setText(String.valueOf(century)); break; } case R.id.yearButton:{ double year = Century*100; timeResultText.setText(String.valueOf(year)); break; } case R.id.monthButton:{ double month = Century*100*12; timeResultText.setText(String.valueOf(month)); break; } case R.id.weekButton:{ double week = Century*100*12*52; timeResultText.setText(String.valueOf(week)); break; } case R.id.dayButton:{ double day = Century*100*12*52*7; timeResultText.setText(String.valueOf(day)); break; } case R.id.hourButton:{ double hour = Century*100*12*52*7*24; timeResultText.setText(String.valueOf(hour)); break; } case R.id.minuteButton:{ double minute = Century*100*12*52*7*24*60; timeResultText.setText(String.valueOf(minute)); break; } case R.id.secondButton:{ double second = Century*100*12*52*7*24*60*60; timeResultText.setText(String.valueOf(second)); break; } } } if(yearText.getText().toString() != null){ //第二个判断语句 double Year = Double.parseDouble(yearText.getText().toString()); monthText.setText( ); weekText.setText( ); dayText.setText( ); hourText.setText( ); minuteText.setText( ); secondText.setText( ); switch(id){ case R.id.centuryButton:{ double century = Year/100+Year%100; timeResultText.setText(String.valueOf(century)); break; } case R.id.yearButton:{ double year = Year*1; timeResultText.setText(String.valueOf(year)); break; } case R.id.monthButton:{ double month = Year*12; timeResultText.setText(String.valueOf(month)); break; } case R.id.weekButton:{ double week = Year*12*52; timeResultText.setText(String.valueOf(week)); break; } case R.id.dayButton:{ double day = Year*12*52*7; timeResultText.setText(String.valueOf(day)); break; } case R.id.hourButton:{ double hour = Year*12*52*7*24; timeResultText.setText(String.valueOf(hour)); break; } case R.id.minuteButton:{ double minute = Year*12*52*7*24*60; timeResultText.setText(String.valueOf(minute)); break; } case R.id.secondButton:{ double second = Year*12*52*7*24*60*60; timeResultText.setText(String.valueOf(second)); break; } } } } }
/
本文档为【Android时间单位换算小程序运行时总是出现错误但又找不出错哪了,麻烦哪位高人指点一上】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索