Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you want to get touch events from the whole area of your layout for this particular test. Try attaching the touch listener to your parent view rather than a separate target view.</p> <p>This isn't a very common approach. In most cases you will want to listen for touch events in a specific child view and if you have other views in your layout that handle touch events (such as a button) they'll take priority over a parent view. See <a href="http://developer.android.com/guide/topics/ui/ui-events.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/ui/ui-events.html</a> for more info about handling UI events.</p> <p>Layout (touch_viewer.xml):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/parent" &gt; &lt;TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello, World!" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And in your activity:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.touch_viewer); final LinearLayout parent = (LinearLayout) findViewById(R.id.parent); final TextView text = (TextView) findViewById(R.id.text); parent.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent ev) { text.setText("Touch at " + ev.getX() + ", " + ev.getY()); return true; } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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