Skip to main content
Cambie la descripción del error que tenia en imagen a texto completo
Origen Enlace

Error logcat Android Studio

01-29 07:44:26.967 12711-12711/com.example.brolix.ctemperatura E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.brolix.ctemperatura, PID: 12711 java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:267) at java.lang.Double.parseDouble(Double.java:301) at com.example.brolix.ctemperatura.MainActivity$3.onEditorAction(MainActivity.java:66) at android.widget.TextView.onEditorAction(TextView.java:4794) at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:139) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:304) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5910) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)

Error logcat Android Studio

01-29 07:44:26.967 12711-12711/com.example.brolix.ctemperatura E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.brolix.ctemperatura, PID: 12711 java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:267) at java.lang.Double.parseDouble(Double.java:301) at com.example.brolix.ctemperatura.MainActivity$3.onEditorAction(MainActivity.java:66) at android.widget.TextView.onEditorAction(TextView.java:4794) at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:139) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:304) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5910) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)

Origen Enlace

java.lang.NumberFormatException: Invalid double: ""

Soy nuevo en esto de android estudio e intento hacer un conversor de temperaturas el problema es que por mas que lo intento sigo consiguiendo este error se supone que todo el programa debo hacerlo orientado a objetos

Error logcat Android Studio

Este es mi main activity tengo entendido que mi problema es la conversión de datos de mi metodo (double)

 EditText C, F, K;


@Override
protected void onCreate(Bundle savedInstanceState) {

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

    C = findViewById(R.id.celciusnumero);
    F = findViewById(R.id.farennumero);
    K = findViewById(R.id.kelvinumero);

    final celcius c = new celcius();
    c.setLetra('C');
    final fahrenheit f = new fahrenheit();
    f.setLetra('F');
    final kelvin k = new kelvin();
    k.setLetra('K');

    try {
        C.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                k.setNumero(Double.parseDouble(K.getText().toString()));
                f.setNumero(Double.parseDouble(F.getText().toString()));
                c.conversion(f);

                F.setText(f.getNumero().toString());

                c.conversion(k);

                K.setText(k.getNumero().toString());
                return false;
            }
        });
        F.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                k.setNumero(Double.parseDouble(K.getText().toString()));
                c.setNumero(Double.parseDouble(C.getText().toString()));

                f.conversion(c);

                C.setText(c.getNumero().toString());

                f.conversion(k);

                K.setText(k.getNumero().toString());

                return false;
            }
        });
        K.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                f.setNumero(Double.parseDouble(F.getText().toString()));
                c.setNumero(Double.parseDouble(C.getText().toString()));

                k.conversion(c);

                C.setText(c.getNumero().toString());

                k.conversion(f);

                F.setText(f.getNumero().toString());

                return false;
            }
        });
    } catch (NumberFormatException e) {

    }
}