Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. static class Person{
  2.  
  3. public long personID;
  4. public String lastName;
  5. public String middleName;
  6. public String firstName;
  7. public String dateOfBirth;
  8. public String personAddress;
  9. public int phoneNumber;
  10. public int driversLicense;
  11. public int socialSecurity;
  12. public String personRace;
  13. public String personSex;
  14. public String personAge;
  15.  
  16. public static Person createFromGenericMap(Map<String, Object> object){
  17.  
  18. Person p = new Person ();
  19.  
  20. p.personID = (long) object.get("personID");
  21. p.lastName = (String) object.get("lastName");
  22. p.middleName = (String) object.get("middleName");
  23. p.firstName = (String) object.get("firstName");
  24. p.dateOfBirth = (String) object.get("dob");
  25. p.personAddress = (String) object.get("address");
  26. p.phoneNumber = (int) object.get("phone");
  27. p.driversLicense = (int) object.get("dl");
  28. p.socialSecurity = (int) object.get("ss");
  29. p.personRace = (String) object.get("race");
  30. p.personSex = (String) object.get("sex");
  31. p.personAge = (String) object.get("age");
  32.  
  33. return p;
  34. }
  35.  
  36. }
  37.  
  38. static class PersonAdapter extends BaseAdapter {
  39.  
  40. private List<Person> people;
  41. private static LayoutInflater inflater = null;
  42.  
  43. public PersonAdapter(Context context, List<Person> people){
  44. this.people = people;
  45. inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  46. }
  47.  
  48.  
  49. @Override
  50. public int getCount() {
  51. return people.size();
  52. }
  53.  
  54. @Override
  55. public Object getItem(int position) {
  56. return people.get(position);
  57. }
  58.  
  59. @Override
  60. public long getItemId(int position) {
  61. Person p = people.get(position);
  62. return p.personID;
  63. }
  64.  
  65. @Override
  66. public View getView(int position, View convertView, ViewGroup parent) {
  67.  
  68. View view = convertView;
  69.  
  70. if (convertView == null){
  71.  
  72. view = inflater.inflate(R.layout.personlist_row, null);
  73.  
  74.  
  75. TextView dl = (TextView) view.findViewById(R.id.tvdl);
  76. TextView last = (TextView) view.findViewById(R.id.tvLastName);
  77. TextView first = (TextView) view.findViewById(R.id.tvFirstName);
  78. TextView middle = (TextView) view.findViewById(R.id.tvMiddleName);
  79. TextView ss = (TextView) view.findViewById(R.id.tvSS);
  80.  
  81.  
  82. Map<String, Object> mperson = new HashMap<String, Object>();
  83. mperson = people.get(position);
  84.  
  85. dl.setText(mperson.getString("dl"));
  86.  
  87.  
  88. }
  89. return view;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement