Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将字符串转换为长强制关闭应用程序_Android_String_Long Integer - Fatal编程技术网

Android 将字符串转换为长强制关闭应用程序

Android 将字符串转换为长强制关闭应用程序,android,string,long-integer,Android,String,Long Integer,我正在编写一个应用程序,需要将文本字段中输入的字符串转换为long,但当我运行该应用程序时,它会强制关闭,有什么问题吗 该应用程序很简单,它只需要在文本字段中输入值,当用户按下按钮时,它开始将该值倒计时到0。(一个回归式天文钟) 代码如下: private CountDownTimer countDownTimer; private boolean timerStarted = false; private Button buttonStart; public TextView textView

我正在编写一个应用程序,需要将文本字段中输入的字符串转换为long,但当我运行该应用程序时,它会强制关闭,有什么问题吗

该应用程序很简单,它只需要在文本字段中输入值,当用户按下按钮时,它开始将该值倒计时到0。(一个回归式天文钟)

代码如下:

private CountDownTimer countDownTimer;
private boolean timerStarted = false;
private Button buttonStart;
public TextView textView;

private final long interval = 1 * 1000;
long tempTempo2;
long minutos4;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cronometro);

    EditText tempTempo = (EditText) findViewById(R.id.tempo);
    minutos4 = Long.parseLong(tempTempo.getText().toString());
    tempTempo2 = Long.valueOf(minutos4);


    buttonStart = (Button) this.findViewById(R.id.button);
    buttonStart.setOnClickListener(this);
    textView = (TextView) this.findViewById(R.id.textView);
    countDownTimer = new CountDownTimerActivity(minutos4, interval);
    textView.setText(textView.getText() + String.valueOf(minutos4/1000));
}

字符串必须是长类型,即不包含
“\n”或空格。尝试先修剪字符串以去除其他字符,然后转换为长字符