protected void onPostExecute(String result) { //result parameter should be final so that it can be used in cross thread operation super.onPostExecute(result);
if (result != null) { try { JSONArray jsonArray = new JSONArray(result); for (int i = 0; i < jsonArray.length(); i++) { JSONObject object = jsonArray.getJSONObject(i); String Brand = object.getString("UserName"); HashMap<String, String> itemList = new HashMap<String, String>(); itemList.put("UserName", Brand); BrandList.add(itemList); } **adapter = new SimpleAdapter(Main2Activity.this, BrandList, R.layout.list, new String[]{"UserName"}, new int[]{R.id.txtTitel}); ((AdapterView<ListAdapter>) listView).setAdapter(adapter); } catch (Exception ex) { ex.printStackTrace(); } } else { Toast.makeText(Main2Activity.this, "Could not get any data.", Toast.LENGTH_LONG).show(); } }