Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.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 - Fatal编程技术网

应用程序在android中意外停止?

应用程序在android中意外停止?,android,Android,我的android应用程序仍然给我以下错误。当我被点击emulator中的应用图标时,不幸的是,我的应用已经停止工作 以下是Logcat错误 下面是代码 谢谢你改变你的方法如下: public void ConvertDollarToRup() { if(!dollars.getText().toString().equals("")) { double val = Double.parseDouble(dollars.getText().toString());

我的android应用程序仍然给我以下错误。当我被点击emulator中的应用图标时,不幸的是,我的应用已经停止工作

以下是Logcat错误

下面是代码


谢谢你

改变你的方法如下:

public void ConvertDollarToRup() {
    if(!dollars.getText().toString().equals("")) {
        double val = Double.parseDouble(dollars.getText().toString());
        rupees.setText(Double.toString(val*56));
    }
}

public void ConvertRupToDollar() {
    if(!rupees.getText().toString().equals("")) {
        double val = Double.parseDouble(rupees.getText().toString());
        dollars.setText(Double.toString(val/56));
    }
}

您正在尝试将空字符串转换为整数:

dollars = (EditText)findViewById(R.id.dollaredtxt);
String rup = dollars.getText().toString();
int convertrup = Integer.parseInt(rup);
rup就是这样:空字符串 如果EditText最初不包含值,则字符串将始终为空


您必须在onClick方法而不是onCreate方法中进行解析。

发布代码和Logcat…longcat?将您的logcat出现错误视为NumberFormatException,这意味着您的ConvertDollarToRup出现问题。因此,请检查它;从字符串rup=dollars.getText.toString;int=0;ifrup.length>0&&rup={int convertrup=Integer.parseIntrup;}否则{convertrup=0;}谢谢你工作得很好,但当我点击应用程序图标时,我认为应该运行gui。
public void ConvertDollarToRup() {
    if(!dollars.getText().toString().equals("")) {
        double val = Double.parseDouble(dollars.getText().toString());
        rupees.setText(Double.toString(val*56));
    }
}

public void ConvertRupToDollar() {
    if(!rupees.getText().toString().equals("")) {
        double val = Double.parseDouble(rupees.getText().toString());
        dollars.setText(Double.toString(val/56));
    }
}
dollars = (EditText)findViewById(R.id.dollaredtxt);
String rup = dollars.getText().toString();
int convertrup = Integer.parseInt(rup);