I am trying to create a ListView in Android. When I click on an item, I want it to scroll it over to the top. How can I do that? Here is the Activity class that I am trying out, item selections works fine but it does not scroll over to the top
public class MyListActivity extends ListActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
//l.setSelection(2);
Toast.makeText(this, position + " selected", Toast.LENGTH_LONG).show();
//l.smoothScrollToPosition(5);
}
}