对不起我的英语不好。我是新的机器人。
我JSON
在Android中有一些问题
(1.)我一直在网上获取信息( JSON
)。如何在特定页面上标记 googlemap 上的所有站点?
(2.1) 我一直在从 Internet( JSON
) 获取信息并在 listView 中显示这些信息。这个listView由两个TextView
(txtV1,txtV2)组成。如何使用keyword_search 来过滤ListView
editText?
(2.2) 如果我点击该选项,相关信息将被传送到下一页并显示。现在,我只能捆绑字符串数据。如何捆绑(lat,lng)并在谷歌地图上标记?
这是 json :
{
"retCode": "1",
"retVal": [
{
"iid": "339",
"sno": "0001",
"mday": "20140711003603",
"lat": "25.0408578889",
"lng": "121.567904444"
},
{
"iid": "340",
"sno": "0002",
"mday": "20140711003508",
"lat": "25.041",
"lng": "121.556945"
}
]
}
这是问题(2.1)代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.station);
oslist = new ArrayList<HashMap<String, String>>();
new JSONParse().execute();
}
private class JSONParse extends AsyncTask<String, String, JSONObject> {
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
sna = (TextView) findViewById(R.id.sna);
ar = (TextView) findViewById(R.id.ar);
}
@Override
protected JSONObject doInBackground(String... args) {
JSONParser jParser = new JSONParser();
// Getting JSON from URL
JSONObject json = jParser.getJSONFromUrl(url);
return json;
}
@Override
protected void onPostExecute(JSONObject json) {
pDialog.dismiss();
try {
// Getting JSON Array from URL
youbike = json.getJSONArray(TAG_retVal);
for (int i = 0; i < youbike.length(); i++) {
JSONObject c = youbike.getJSONObject(i);
// Storing JSON item in a Variable
final String iid = c.getString(TAG_iid);
final String sno = c.getString(TAG_sno);
final String mday = c.getString(TAG_mday);
final String lat = c.getString(TAG_lat);
final String lng = c.getString(TAG_lng);
// Adding value HashMap key => value
final HashMap<String, String> map = new HashMap<String, String>();
map.clear();
map.put(TAG_iid, iid);
map.put(TAG_sno, sno);
map.put(TAG_mday, mday);
map.put(TAG_lat, lat);
map.put(TAG_lng, lng);
oslist.add(map);
list = (ListView) findViewById(R.id.list);
ListAdapter adapter = new SimpleAdapter(station.this,
oslist, R.layout.station_list, new String[] {
TAG_iid, TAG_sno }, new int[] { R.id.sno,
R.id.iid });
list.setAdapter(adapter);
// bundle to next page
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
Intent intent = new Intent();
intent.setClass(station.this, station_1.class);
Bundle b = new Bundle();
b.putString("TAG_iid",
oslist.get(+position).get("iid"));
b.putString("TAG_sno",
oslist.get(+position).get("sno"));
b.putString("TAG_mday",
oslist.get(+position).get("mday"));
b.putString("TAG_lat",
oslist.get(+position).get("lat"));
b.putString("TAG_lng",
oslist.get(+position).get("lng"));
intent.putExtras(b);
startActivity(intent);
}
});
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}