Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Placement of some of your code was wrong. I have attempted to fix it. See if the following works for you:</p> <pre><code>package com.example.MyProject; import android.os.Bundle; import android.app.Activity; import android.text.Editable; import android.view.FocusFinder; import android.view.Menu; import android.widget.EditText; public class MainActivity extends Activity { private android.widget.EditText editText1; private android.widget.EditText editText2; private android.widget.TextView resultsText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText1 = (EditText)findViewById(R.id.textView13); editText2 = (EditText)findViewById(R.id.textView15); resultsText = (android.widget.TextView)findViewById(R.id.textView16); android.text.TextWatcher inputTextWatcher = new android.text.TextWatcher() { public void afterTextChanged(android.text.Editable s) { calculateResult(); } public void beforeTextChanged(CharSequence s, int start, int count, int after){} public void onTextChanged(CharSequence s, int start, int before, int count){} }; editText1.addTextChangedListener(inputTextWatcher); editText2.addTextChangedListener(inputTextWatcher); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } private void calculateResult() throws NumberFormatException { Editable editableValue1 = editText1.getText(); Editable editableValue2 = editText2.getText(); double value1 = 0.0, value2 = 0.0, result; if (editableValue1 != null) value1 = Double.parseDouble(editableValue1.toString()); if (editableValue2 != null) value2 = Double.parseDouble(editableValue2.toString()); result = ((0.5 * value1) / 6.1) * value2; resultsText.setText(String.valueOf(result)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload