I'm trying to populate my Listview with Data from my JSON file. but for some reason it outputs just 35 times the same line into the listview. Does anybody know why?
JSONArray json = new JSONArray(data);
ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
try {
for(int i=0;i<json.length();i++){
JSONObject e =json.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("Name", "Vorname: " + e.getString("meta_value"));
map.put("orderid", "id: " + e.getString("post_id"));
arrayList.add(map);
}
final ArrayAdapter arrayAdapter = new ArrayAdapter(activity2.this, android.R.layout.simple_list_item_1,arrayList);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
ListView myListView = (ListView) findViewById(R.id.list);
myListView.setAdapter(arrayAdapter);
}
});