在 Android 应用程序中,我有一个搜索选项,该选项使用网络服务(在搜索栏中搜索关键字),并在屏幕上显示结果。下次,当我搜索不同的关键字时,结果被附加到第一个结果并显示。我想要的是,删除/清除第一个结果,然后显示第二个结果,而不是将结果添加到第一个结果。请作为 Anderroid 的 Ambie 帮助 。
public class Srch_Widget extends ListActivity {
ListView lv;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mysearchscreen);
//In the search box, i will be typing an alphabet and click on "GO button"
goButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//I m using webservices to retrieve data(JSON String) and will get "EmpName", "EmpID",
"Salary" and the data will be in a single list called "searchlist" that I used below in
ser_listadapter.(if you want I can paste the entire webservices)
ser_listadapter();
}
});
}
public void ser_listadapter() {
ListAdapter adapter = new SimpleAdapter(this,searchlist,
R.layout.searchmain, new String[] { "EmpName", "EmpID",
"Salary" }, new int[] {
R.id.eid, R.id.ename, R.id.sal});
//"searchmain" layout contains 3 textviews with id s: eid,ename,sal
setListAdapter(adapter);
lv = getListView();
lv.setTextFilterEnabled(true);
}
}