软工每日总结6

今天的工作是将百度地图的建议结果查询集成到我们的软件中:

主要代码:

mSuggestionSearch = SuggestionSearch.newInstance();
mSuggestionSearch.setOnGetSuggestionResultListener(this);
addTextChangedListener(new TextWatcher() {

@Override
public void afterTextChanged(Editable arg0) {
Log.e("e","after");
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
Log.e("e","before");
}

@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2,
int arg3) {
Log.e("e","on");
if (cs.length() <= 0) {
return;
}
String city = "北京";
/**
* 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新
*/
mSuggestionSearch
.requestSuggestion((new SuggestionSearchOption())
.keyword(cs.toString()).city(city));
}
});

@Override
public void onGetSuggestionResult(SuggestionResult res) {
if (res == null || res.getAllSuggestions() == null) {
Log.e("e", "invalid");
return;
}
str=new String[10];
int i=0;
for (SuggestionResult.SuggestionInfo info : res.getAllSuggestions()) {
if (info.key != null&&i<10) {
str[i] = info.key;
Log.e("e",info.key);
i++;
}
}
sugAdapterSt = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,str);
editSt.setAdapter(sugAdapterSt);
sugAdapterEd = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,str);
editEn.setAdapter(sugAdapterEd);
}
遇到的问题:android studio导入eclipse的安卓工程时出现开发环境不兼容的情况,一些图片资源无法正常使用,在降低AS使用的gradle版本之后得到暂时解决,还有就是windows下的开发工具大多不使用utf-8编码,导致导入到linux环境后中文乱码。
posted @ 2016-07-06 09:34  13070026王志东  阅读(233)  评论(5编辑  收藏  举报