Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following works using a touch screen on the jetboy sample android app. Joes code worked with one tweak to make it shine the background thru. The only line I added was </p> <pre><code>android:background="#0000" android:layout_height="fill_parent" android:layout_height="fill_parent" </code></pre> <p>Thanks Joe (above).</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TextView textView = (TextView)findViewById(R.id.textView); // this is the view on which you will listen for touch events final View touchView = findViewById(R.id.touchView); touchView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { textView.setText("Touch coordinates : " + String.valueOf(event.getX()) + "x" + String.valueOf(event.getY())); return true; } }); } </code></pre> <p>layout code</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.android.samples.jetboy.JetBoyView android:id="@+id/JetBoyView" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;TextView android:id="@+id/touchView" android:background="#0000" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;TextView android:id="@+id/textView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Hello World, TestActivity" /&gt; &lt;/FrameLayout&gt; </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