Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not <strong>ordinarily</strong> possible; the top button will absorb the button click event and not pass it on to the one behind it. It is not clear whether or not you want to obtain this behaviour or avoid it, nonetheless, you can force it by propagating the event manually across the click listeners.</p> <p>Here is one way (there are a few); assume buttonOne is on top of buttonTwo:</p> <pre><code>final Button buttonOne = (Button) findViewById(...); final Button buttonTwo = (Button) findViewById(...); buttonOne.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d("ButtonTest", "ButtonOne clicked"); buttonTwo.performClick(); } }); buttonTwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d("ButtonTest", "ButtonTwo clicked"); } }); </code></pre> <p>The click event enters the listener on button one, which then causes a click event on button two.</p> <p>Here is another way which would work (and could be changed to support long click events easily):</p> <pre><code>final Button buttonOne = (Button) findViewById(...); final Button buttonTwo = (Button) findViewById(...); final OnClickListener listenerTwo = new OnClickListener() { @Override public void onClick(View v) { Log.d("ButtonTest", "ButtonTwo clicked"); } }; final OnClickListener listenerOne = new OnClickListener() { @Override public void onClick(View v) { Log.d("ButtonTest", "ButtonOne clicked"); listenerTwo.onClick(buttonTwo); } }; buttonOne.setOnClickListener(listenerOne); buttonTwo.setOnClickListener(listenerTwo); </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.
    3. 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