The problem is that each time I click on item it is replacing the item that was added early, so the first listview has only the last added item. Here is my code:
lvUsersList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
pb.setVisibility(View.VISIBLE);
final Contacts contact = (Contacts) adapter.getItem(position);
final RequestParams params = new RequestParams();
params.add("member", contact.getId());
params.add("id", gcId);
AsyncHttpClient asyncClient = new AsyncHttpClient();
asyncClient.addHeader("User", userId);
asyncClient.post("http://prev.gio.uz/addGroupChatMember", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
pb.setVisibility(View.GONE);
String json = new String(responseBody);
try {
JSONObject object = new JSONObject(json);
JSONObject jsonObject = object.getJSONArray("data").getJSONObject(0);
Log.i("myLogs", "gc member added successfully");
} catch (JSONException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext(), "Group member added", Toast.LENGTH_SHORT).show();
List<AddedUsers> addedUsersList = new ArrayList<AddedUsers>();
AddedUsers au = new AddedUsers();
au.setId(contact.getId());
au.setFullName(contact.getFullName());
addedUsersList.add(au);
The code is ugly as ****, hope you understand, I'll explain more if needed