I am using following method to populate a listview inside a fragment class.
private void showEmployee(){
JSONObject jsonObject = null;
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String, String>>();
try {
jsonObject = new JSONObject(JSON_STRING);
JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY);
for(int i = 0; i<result.length(); i++){
JSONObject jo = result.getJSONObject(i);
String cia = jo.getString(Config.TAG_CIA);
String fn = jo.getString(Config.TAG_FN);
String ln = jo.getString(Config.TAG_LN);
String ad1 = jo.getString(Config.TAG_AD1);
String ad2 = jo.getString(Config.TAG_AD2);
String type = jo.getString(Config.TAG_TYPE);
String city = jo.getString(Config.TAG_CITY);
String state = jo.getString(Config.TAG_STATE);
String zip = jo.getString(Config.TAG_ZIP);
String phone = jo.getString(Config.TAG_PHONE);
String ext = jo.getString(Config.TAG_EXT);
String fromto = jo.getString(Config.TAG_FROMTO);
Log.d("HOLA ADDRESSES", "FROM O TO: " + fromto);
String user = jo.getString(Config.TAG_USER);
String id_address = jo.getString(Config.TAG_ID_ADDRESS);
HashMap<String,String> employees = new HashMap<>();
employees.put(Config.TAG_CIA,cia);
employees.put(Config.TAG_LN,fn);
employees.put(Config.TAG_FN,ln);
employees.put(Config.TAG_AD1,ad1);
employees.put(Config.TAG_AD2,ad2);
employees.put(Config.TAG_TYPE,type);
employees.put(Config.TAG_CITY,city);
employees.put(Config.TAG_STATE,state);
employees.put(Config.TAG_ZIP,zip);
employees.put(Config.TAG_PHONE,phone);
employees.put(Config.TAG_EXT,ext);
employees.put(Config.TAG_FROMTO,fromto);
employees.put(Config.TAG_USER,user);
employees.put(Config.TAG_ID_ADDRESS,id_address);
list.add(employees);
}
} catch (JSONException e) {
e.printStackTrace();
}
ListAdapter adapter = new SimpleAdapter(
getActivity(), list, R.layout.addresses_list_item,
new String[]{Config.TAG_CIA,
Config.TAG_FN,
Config.TAG_LN,
Config.TAG_AD1,
Config.TAG_AD2,
Config.TAG_TYPE,
Config.TAG_CITY,
Config.TAG_STATE,
Config.TAG_ZIP,
Config.TAG_PHONE,
Config.TAG_EXT,
Config.TAG_FROMTO,
Config.TAG_USER,
Config.TAG_ID_ADDRESS},
new int[]{R.id.cia,
R.id.fn,
R.id.ln,
R.id.ad1,
R.id.ad2,
R.id.type,
R.id.city,
R.id.state,
R.id.zip,
R.id.phone,
R.id.ext,
R.id.fromto,
R.id.user,
R.id.id_address});
listView.setAdapter(adapter);
}
Now I want to include a button on every row from the list and be able to change the button text on every row depending on the value from one of the items.
I have included the button inside the listview item layout file.
I don´t know where to put the button reference on this method.
Thank you.