I have an activity with the following layout.

So in this screen, initally the ListViewis empty. I type some text in EditTextand click on the search icon next to it, the app fetched the items from server and populates the ListView. Now the problem is that the ListView scrolls down to the last item.
Code in my onClick() of search Button
String str_searchTxt = mEt_search.getText().toString().trim();
if (str_searchTxt.length() == 0) {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.ENTER_MANDATORY),
Toast.LENGTH_LONG).show();
return;
}
// get items List in araryList
itemList = getItemList(messageHandler,str_searchTxt);
Code in my message handler:
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 2:
String txt = msg.getData().getString("text");
Log.i("Result", txt);
progressDialog.dismiss();
if (txt.equalsIgnoreCase("success")) {
lview3 = (ListView) findViewById(R.id.listView1);
adapter = new ListViewCustomAdapter(
SearchAssetActivity.this, itemList);
lview3.setAdapter(adapter);
lview3.setOnItemClickListener(SearchAssetActivity.this);
lview3.requestFocus();
lview3.setSelection(0);
}
}
You can use setSelection(position) of ListView,
Else you can try,