Note that there are some explanatory texts on larger screens.

plurals
  1. POMy android app isn't displaying anything when i add numbers to it's text field
    primarykey
    data
    text
    <p>I'm new to programming for the android and I'm trying to create a simple program.</p> <p>If the user enters a number in the attacker ws field and the same number defender ws field you should get an answer.</p> <p>I'm missing something.</p> <pre><code>package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class HelloAndroid extends Activity implements OnClickListener { private EditText text, text2, text3; private Button btutorial1; int result = text.toString().compareTo(text2.toString()); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = new TextView(this); tv.setText("I hope this works"); text = (EditText) findViewById(R.id.editText1); text2 =(EditText) findViewById(R.id.editText2); text3 = (EditText) findViewById(R.id.editText3); btutorial1 = (Button) findViewById(R.id.button1); btutorial1.setOnClickListener(this); } public void onClick(View view) { switch (view.getId()) { case R.id.button1: if (text.getText().toString().equals(1) &amp;&amp; text2.getText().toString().equals(2)) { text3.setText("Five and above"); return; } else if (text.getText().toString().equals(1) &amp;&amp; text2.getText().toString().equals(3)) { text3.setText("Five and above"); return; } else if (text.getText().toString().equals(1) &amp;&amp; text2.getText().toString().equals(3)) { text3.setText("Four and above"); return; } else if (text.getText().toString().equals(text2.getText().toString())) { text3.setText("Four and above"); return; } else { text3.setText("Not Working"); return; } } } } </code></pre> <p>My XML class named main</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter Attacker ws"&gt;&lt;/TextView&gt; &lt;EditText android:id="@+id/editText1" android:text="" android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="number" android:visibility="visible"&gt;&lt;/EditText&gt; &lt;TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Enter Opponent ws"&gt;&lt;/TextView&gt; &lt;EditText android:id="@+id/editText2" android:text="" android:layout_height="wrap_content" android:layout_width="match_parent" android:visibility="visible" android:inputType="number"&gt;&lt;/EditText&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Calculate" android:visibility="visible" android:onClick="myClickHandler"&gt;&lt;/Button&gt; &lt;EditText android:id="@+id/editText3" android:layout_height="wrap_content" android:layout_width="match_parent" android:name="result" android:editable="false"&gt;&lt;/EditText&gt; &lt;/LinearLayout&gt; </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. 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