我有一個以下佈局的活動。列表視圖滾動到屏幕底部
所以在這個屏幕上,initally的ListView
是空的。我在EditText
中鍵入一些文本,然後單擊它旁邊的搜索圖標,應用程序從服務器獲取項目並填充ListView
。現在的問題是,ListView
滾動到最後一個項目。
代碼在我的搜索Button
onClick()
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);
:
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);
}
}
不明確刷新它 –
發表您的搜索按鈕的onClick代碼 – MAC