I got the response from Json and need to display the result as in ordered name. After implementing the Hashmap I realized that it was not sorted alphabetically How do i do that?
public ArrayList<HashMap<String, String>> contactList= new ArrayList<HashMap<String, String>>();
Collections.sort(contactList, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});
Code:
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (pDialog.isShowing())
pDialog.dismiss();
SimpleAdapter adapter = new SimpleAdapter(
HomeActivity.this, contactList,
R.layout.list_item, new String[] {TAG_FNAME}, new int[] {R.id.textView1});
setListAdapter(adapter);
adapter.notifyDataSetChanged();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent,
View view, int position, long ids) {
Intent i = new Intent(getApplicationContext(),
SingleListActivity.class);
HashMap<String, String> contact = contactList.get(position);
i.putExtra("id", id);
i.putExtra("firstName", firstname);
i.putExtra("lastName", lastname);
i.putExtra("headline", headline);
i.putExtra("pictureUrl", pictureUrl);
i.putExtra("url", url);
startActivity(i);
}
});
In this it contains both first name and last name how do i do that?