Android button - How to set focusable to true and still accept onClick listener on first click?
<p><strong>UPDATE</strong></p>

<p>I've solved the clicking issue by removing the two focusable lines from the button style and using the onClick event handler to call <code>requestFocusFromTouch();</code></p>

<p>Unfortunately I'm left with an issue that requestFocusFromTouch() focuses the wrong button. It always focuses the first button not the button I call the method on. Is this an android bug or expected behaviour and what I can I do for a work around?</p>

<p>The code now looks like this for the onClick event</p>

<pre><code>public void onClick(View v) {
    switch (v.getId()) {
            case R.id.btn_home:
                Intent i = new Intent(this, QuizMenu.class);
                startActivity(i);
                v.requestFocusFromTouch();
            break;
            case R.id.btn_support:
                Intent i1 = new Intent(this, Support.class);
                startActivity(i1);
                v.requestFocusFromTouch();
                View btnSupport = findViewById(R.id.btn_support);
                btnSupport.setSelected(true);
                btnSupport.requestFocusFromTouch();
            break;
            // More buttons go here (if any) ...
    }
}
</code></pre>

<p><strong>END OF UPDATE</strong></p>

<p>I have an android button that has the following style</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
    &lt;style name="MnuBtnStyle"&gt;
        &lt;item name="android:ellipsize"&gt;marquee&lt;/item&gt;
        &lt;item name="android:scrollHorizontally"&gt;true&lt;/item&gt;
        &lt;item name="android:focusable"&gt;true&lt;/item&gt;
        &lt;item name="android:focusableInTouchMode"&gt;true&lt;/item&gt;
        &lt;item name="android:singleLine"&gt;true&lt;/item&gt;
        &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt;
        &lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt;
        &lt;item name="android:layout_marginTop"&gt;1dip&lt;/item&gt; 
        &lt;item name="android:layout_marginBottom"&gt;1dip&lt;/item&gt;
        &lt;item name="android:textSize"&gt;10dp&lt;/item&gt;
        &lt;item name="android:layout_weight"&gt;1&lt;/item&gt;
        &lt;item name="android:textColor"&gt;#00FF00&lt;/item&gt;
        &lt;item name="android:typeface"&gt;monospace&lt;/item&gt;
    &lt;/style&gt;
&lt;/resources&gt;
</code></pre>

<p>I have an on click listener that looks like this</p>

<pre><code>public void onClick(View v) {
    switch (v.getId()) {
            case R.id.btn_home:
                Intent i = new Intent(this, HomeScreen.class);
                startActivity(i);
            break;
            // More buttons go here ...
    }
}
</code></pre>

<p>I have an image on the button and the selector looks like this</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;selector
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_pressed="true"
        android:drawable="@drawable/ic_tab_home_pressed" /&gt; &lt;!-- pressed --&gt;
    &lt;item android:state_focused="true"
        android:drawable="@drawable/ic_tab_home_pressed" /&gt; &lt;!-- pressed --&gt;
    &lt;item android:drawable="@drawable/ic_tab_home_unpressed" /&gt; &lt;!-- default/unchecked --&gt;
&lt;/selector&gt;
</code></pre>

<p>The layout that uses the button and the button looks like this</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:id="@+id/top_menu_bar"
      android:layout_marginTop="2dip" 
      android:padding="0dip"
      android:background="@android:drawable/bottom_bar"
      android:layout_alignParentTop="true"
      android:gravity="top"
      android:layout_height="@dimen/menu_bar_height"
      android:layout_width="fill_parent"&gt;
      &lt;Button
          android:id="@+id/btn_home"
          android:text="@string/btn_home"
          android:drawableTop="@drawable/home_button"
          style="@style/MnuBtnStyle"
      /&gt;
...
</code></pre>

<p>there are other buttons and this layout is acting as a top menu bar that is included in whatever layout needs it.</p>

<p>The onClick event for the button is only fired on second click of the button due to the focusable lines.</p>

<pre><code>        &lt;item name="android:focusable"&gt;true&lt;/item&gt;
        &lt;item name="android:focusableInTouchMode"&gt;true&lt;/item&gt;
</code></pre>

<p>The first click sets focus on the button then the second click fires the onClick event listener
I need to combine the two together so that the first click sets focus AND fires the onClick event listener. Can this be done?</p>

<p>If I remove the two focusable lines the buttons behave normally but I want to show that the button is focused and I want the scrolling text inside the button that <code>&lt;item name="android:ellipsize"&gt;marquee&lt;/item&gt;</code> gives me</p>

<p>Any ideas greatly appreciated</p>
