我正在为韩国客户开发一个安卓应用程序。我必须根据按键搜索数据,例如,如果我按 A,那么从 A 开始的所有数据都显示在 listview 中,其中数据来自 listview 中的Web 服务。可能吗?
如果是,那么该怎么做。如果可能的话,给我一些我可以使用的代码或链接?
谢谢。
我正在为韩国客户开发一个安卓应用程序。我必须根据按键搜索数据,例如,如果我按 A,那么从 A 开始的所有数据都显示在 listview 中,其中数据来自 listview 中的Web 服务。可能吗?
如果是,那么该怎么做。如果可能的话,给我一些我可以使用的代码或链接?
谢谢。
Yes its possible.You can add TextChangedListener on your edittext and in the onTextChanged event get the date from the webserver as json or xml and parse that data and show the data in a listview.
edittext.addTextChangedListener(textWacther);
final TextWatcher textWacther = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
getdata();
}
};
Getting the data from webserver this question might be helpful for you How to connect to a Remote Database with Webservices?
在@Syam的代码中调用getData()的地方,根据编辑文本中输入的文本获取新数据,放到有ListView源的数组中,别忘了调用setDataSetChanged()适配器到底。