title: Android ListView scrollTo
body: <p>I have a <code>LinearLayout</code> that contains some other views and among those a <code>ListView</code>.
  This view is loaded from another one by clicking a button.</p>
  
  <p>This button somehow specify what element in the ListView needs to be the first visible one in the list. The elements that populates the list are retrieved via HTTP from an external server.</p>
  
  <p>The problem is that I can get the Nth element to be the first in the list.
  Please note, I do not want to move it form it current position to a new one, I want the list to scroll.</p>
  
  <p>I have tried with <code>setSelected()</code> and <code>scrollTo(x,y)</code> and <code>scrollBy(x,y)</code> but with no luck.</p>
  
  <p>I have also gave a try to this pice of code, as ugly as it is, but I just wanted to try f it was working:</p>
  
  <pre><code>ListView categoryList = (ListView)findViewById(R.id.category_list);
          categoryList.post(new Runnable() {
              @Override
              public void run() {
                  Log.d(this.getClass().getName(), "CategoryActivity.scrollToIndex: " + CategoryActivity.scrollToIndex);
                  if(CategoryActivity.scrollToIndex&gt;0){
                      ListView categoryList = (ListView)findViewById(R.id.category_list);
                      categoryList.setScrollContainer(true);
                      categoryList.scrollTo(4, CategoryActivity.scrollToIndex * 50);
                      categoryList.requestLayout();
  
                  }
              }
          });
  </code></pre>
  
  <p>And this gave me some success, but the ListView was then behaving <em>crazy</em> in a way I am not even able to describe....</p>
  
  <p>Any idea?</p>