Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of, the title should describe what the problem is.</p> <p>Second, what is the calculation you are talking about? Is that something say, java specific and you need only help with how the Android view system works?</p> <p>I wrote some sample code for you. It consists of an XML that shows the views and some java code.</p> <p>XML: activity_main.xml</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;EditText android:id="@+id/edit_text" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="calculate" /&gt; &lt;TextView android:id="@+id/text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Code: MainActivity</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final EditText editText = (EditText) findViewById(R.id.edit_text); Button button = (Button) findViewById(R.id.button); final TextView textView = (TextView) findViewById(R.id.text_view); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String calculation = doCalculation(editText.getText().toString()); textView.setText(calculation); } }); } private String doCalculation(String string) { return "EditText: " + string + ", doCalculation returned the message"; } } </code></pre>
 

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