title: How to set focus on list view at 0 index
body: <p>I am trying to set focus on list view when it is loaded. I have a requirement where I want to implement navigation on list view like when an up button is pressed I want it to move one step up and similar for down button. Till now I have tried almost most of the methods like 
  <strong>set selection(position),listview.requestfocus(), list.setSelected(true),list.setItemsCanFocus(true)</strong> but nothing has worked so far.
  I have also tried this method  to get the view inside the list view and it works fine :</p>
  
  <pre><code>public View getViewByPosition(int pos, ListView listView) {
      final int firstListItemPosition = listView.getFirstVisiblePosition();
      final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
  
      if (pos &lt; firstListItemPosition || pos &gt; lastListItemPosition ) {
          return listView.getAdapter().getView(pos, null, listView);
      } else {
          final int childIndex = pos - firstListItemPosition;
          return listView.getChildAt(childIndex);
      }
  }
  then I am getting the view and trying to set focus..however it does not work                
  
  runOnUiThread(new Runnable() {
                  public void run() {
                      getViewByPosition(0, list);
                      View v = getViewByPosition(0, list);
  
                      Log.v("WifiScanReceiver", "View found: " + v);
                      v.setFocusable(true);
                      v.setFocusableInTouchMode(true);
                      v.requestFocus();
  
  
                  }
              });
  </code></pre>
  
  <p>Any suggestions to achieve the focus would be appreciated.I have researched a lot and nothing has worked so far.</p>
  
  <pre><code>public class MainActivity extends Activity {
      ListView listView ;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Get ListView object from xml
          listView = (ListView) findViewById(R.id.list);
  
          // Defined Array values to show in ListView
          String[] values = new String[] { "Android List View", 
                                           "Adapter implementation",
                                           "Simple List View In Android",
                                           "Create List View Android", 
                                           "Android Example", 
                                           "List View Source Code", 
                                           "List View Array Adapter", 
                                           "Android Example List View" 
                                          };
  
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, values);
  
  
  
          listView.setAdapter(adapter); 
          listView.post(new Runnable() {
  
              @Override
              public void run() {
                  listView.setSelection(0);
              }
          });
  </code></pre>