这里我试图显示从mysql db获取的状态列表,代码显示列表但是同一项目被多次显示。
请帮助我删除重复的条目我已粘贴我的功能
protected void showList()
{
try{
JSONObject jsonObj = new JSONObject(myJSON);
peoples = jsonObj.getJSONArray(TAG_RESULTS);
for(int i=0;i<peoples.length();i++){
JSONObject c = peoples.getJSONObject(i);
// String loc = c.getString(TAG_LOCATION);
//String dist = c.getString(TAG_DIST);
String state = c.getString(TAG_STATE);
HashMap<String,String> persons = new HashMap<String,String>();
//persons.put(TAG_LOCATION,loc);
//persons.put(TAG_DIST,dist);
if(!personList.contains(state.toString())) {
persons.put(TAG_STATE, state);
personList.add(persons);
}
}
ListAdapter adapter = new SimpleAdapter(
Location.this,personList,R.layout.simple_list_item_1,
new String[]{TAG_STATE},
new int[]{R.id.tvLocation}
);
list.setAdapter(adapter);
}catch (JSONException e){
e.printStackTrace();
}
pd1.dismiss();
}
答案 0 :(得分:0)
MEDIA_ROOT='<the full path to your media folder>' (i.e: '/home/ike/project/media/')
MEDIA_URL='/media/'