android 闪退 无日志,求助,简单UI界面,调试总是闪退,还没有LOG错误日志???...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

折腾了快一天了,还不知道哪里出错了

3546c8f94fbd2f518df6f1624b444f7f.png

package com.example.love;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

import android.R.integer;

import android.app.Activity;

import android.os.Bundle;

import android.widget.Button;

import android.widget.TextView;

public class MainActivity extends Activity {

private TextView txt2=null;

private TextView txt4=null;

private TextView txt5=null;

private Button btn1=null;

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

this.txt2=(TextView) super.findViewById(R.id.txt2);

this.txt4=(TextView) super.findViewById(R.id.txt4);

this.txt5=(TextView) super.findViewById(R.id.txt5);

this.btn1=(Button) super.findViewById(R.id.btn1);

txt2.setText(getdate());

txt4.setText(datesub());

txt5.setText(getTime());

}

public String getdate() {

Calendar c = Calendar.getInstance();

int mYear = c.get(Calendar.YEAR);

int mMonth = c.get(Calendar.MONTH) + 1;

int mDay = c.get(Calendar.DAY_OF_MONTH);

String time = mYear + "-" + mMonth + "-" + mDay;

return time;

}

private String datesub() {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Date date0 = null;//新对象要初始化

try {

date0 = sdf.parse("2014-01-01");

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Date date1 = null;

try {

date1 = sdf.parse("2014-01-05");

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

long time0 = date0.getTime();

long time1 = date1.getTime();

String s = ""+(time1-time0)/1000/3600/24;

return s;

}

public String getTime() {

Calendar c = Calendar.getInstance();

int mYear = c.get(Calendar.YEAR);

int mMonth = c.get(Calendar.MONTH) + 1;

int mDay = c.get(Calendar.DAY_OF_MONTH);

int mHour = c.get(Calendar.HOUR_OF_DAY);

int mMinute = c.get(Calendar.MINUTE);

int mSecond = c.get(Calendar.SECOND);

String time = mYear + "-" + mMonth + "-" + mDay + " " +format(mHour) +":" + format(mMinute) + ":" + format(mSecond);

return time;

}

private String format(int x) {

String s = ""+x;

if(s.length() == 1)

s = "0"+s;

return s;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值