title: How can a button get the focus?
body: <p>There are quite a few posts touching this topic.  I thought I should ask this simple question hoping to clarify this.</p>
  
  <p>I am unable to achieve setting the focus on a button.  I know I probably miss something fundamental. Here is the simple layout:</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="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Button"
      android:focusable="true" /&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The following is the simple code in onCreate():</p>
  
  <pre><code>        Button button = (Button)findViewById(R.id.button1);
          button.setFocusable(true);
          button.requestFocus();
          button.setText("Debug");  //Just to show the code here has been executed
  </code></pre>
  
  <p>It simply does not work (i.e. the button does not get the focus).</p>
  
  <p>Any correction of my error or misunderstanding will be greatly appreciated.</p>