@Override public void onResume() { super.onResume(); ContactService cs = new ContactService(getContext()); cs.getMyContactList( new IUpdateListener<List<Contact>>() { @Override public void success(boolean isSuccess, List<Contact> data) { list.clear(); list.addAll(data); adapter.notifyDataSetChanged(); } @Override public void fail(VolleyError error) {} }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (null != rootView) { ViewGroup parent = (ViewGroup) rootView.getParent(); if (null != parent) { parent.removeView(rootView); } } else { rootView = inflater.inflate(R.layout.fragment_mycontact, container, false); ListView listView = (ListView) rootView.findViewById(R.id.listView); ContactService cs = new ContactService(getContext()); adapter = new ContactAdapter(getContext(), list); listView.setAdapter(adapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(getActivity(), ContactDetailsActivity.class); intent.putExtra("id", list.get(position).getContactsid() + ""); startActivity(intent); } }); cs.getMyContactList( new IUpdateListener<List<Contact>>() { @Override public void success(boolean isSuccess, List<Contact> data) { list.clear(); list.addAll(data); adapter.notifyDataSetChanged(); } @Override public void fail(VolleyError error) {} }); } return rootView; }