我正在编写一个搜索函数来访问库网站.当提交查询字符串时,程序启动一个新线程来解析Web上的信息.它在AVD上正常运行,但我的HTC DesireHD反复显示搜索结果(如果实际结果是1. 2. 3.它看起来是1. 2. 3. 1. 2. 3.).我在onQueryTextSubmit方法中设置了断点,发现方法onQueryTextSubmit()中的代码被执行了两次.这是我的代码:
sv.setOnQueryTextListener(new OnQueryTextListener(){
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
list.clear();
String str = null;
try {//encoding Chinese character
str = new String(query
.trim().getBytes(), "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
SearchPost sp = new SearchPost(SEARCH_URL + str);
new Thread(sp).start();
return false;
}
});
protected class SearchPost implements Runnable{
public String url = "";
SearchPost(String urls){
url = urls;
}
public SearchPost() { …Run Code Online (Sandbox Code Playgroud) 配置即时运行后,运行按钮有一个小的黄色霹雳.但是当我运行应用程序时,Android Studio仍然执行完整的构建和安装,图片中列出了完整的消息.
我在http://tools.android.com/tech-docs/instant-run中搜索了官方文档,但没有关于"多个进程"的任何内容.我想知道"多个进程"意味着编译或我的Android应用程序.
我应该配置什么来关闭多个进程并体验即时运行?