嗨,我正在列表视图中过滤数据,有一个带有搜索功能的编辑框....
现在,如果我输入 la 并输入搜索按钮,过滤器将完成....
下面是代码
double lat[] = new double[] { 32.711857, 32.80964, 32.751261, 32.753932, 32.751622, 32.769955, 32.770677, 34.304875, 32.854782, 32.761829 };
double lon[] = new double[] { -117.159901, -117.238223, -117.247137, -117.16355, -117.165782, -117.162005, -117.16561, -118.461662, -117.27464,
-117.172343 };
double latitude, longitude;
String places[] = new String[] { "Gaslamp", "Pacific Beach", "Ocean Beach", "Uptown", "Hillcrest", "Mission Valley", "Fashion Valley",
"La Jolla", "San Diego","North Park" };
int zipCode[] = new int[] { 92101, 92109, 92107, 92103, 92103, 92123, 92008, 92037, 92115, 92104 };
现在,当我单击 SearchImageView 时,将执行以下代码...
ImageView imgSearch = (ImageView) findViewById(R.id.ivIconSearch);
imgSearch.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (adapter != null) {
adapter.getFilter().filter(edtSearch.getText().toString());
adapter.notifyDataSetChanged();
}
return true;
}
});
现在,当我单击列表视图时,将执行以下代码..
adapter = new SimpleAdapter(PredefinedLocation.this, fillMaps, R.layout.list_item_deal, new String[]{"name"}, new int[]{R.id.name});
// Adding data into listview
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
// TODO Auto-generated method stu
}
});
在这里,我应该编写什么代码才能获得可过滤的纬度,经度,邮政编码.....