Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Person{
- public long personID;
- public String lastName;
- public String middleName;
- public String firstName;
- public String dateOfBirth;
- public String personAddress;
- public int phoneNumber;
- public int driversLicense;
- public int socialSecurity;
- public String personRace;
- public String personSex;
- public String personAge;
- public static Person createFromGenericMap(Map<String, Object> object){
- Person p = new Person ();
- p.personID = (long) object.get("personID");
- p.lastName = (String) object.get("lastName");
- p.middleName = (String) object.get("middleName");
- p.firstName = (String) object.get("firstName");
- p.dateOfBirth = (String) object.get("dob");
- p.personAddress = (String) object.get("address");
- p.phoneNumber = (int) object.get("phone");
- p.driversLicense = (int) object.get("dl");
- p.socialSecurity = (int) object.get("ss");
- p.personRace = (String) object.get("race");
- p.personSex = (String) object.get("sex");
- p.personAge = (String) object.get("age");
- return p;
- }
- }
- static class PersonAdapter extends BaseAdapter {
- private List<Person> people;
- private static LayoutInflater inflater = null;
- public PersonAdapter(Context context, List<Person> people){
- this.people = people;
- inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
- @Override
- public int getCount() {
- return people.size();
- }
- @Override
- public Object getItem(int position) {
- return people.get(position);
- }
- @Override
- public long getItemId(int position) {
- Person p = people.get(position);
- return p.personID;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view = convertView;
- if (convertView == null){
- view = inflater.inflate(R.layout.personlist_row, null);
- TextView dl = (TextView) view.findViewById(R.id.tvdl);
- TextView last = (TextView) view.findViewById(R.id.tvLastName);
- TextView first = (TextView) view.findViewById(R.id.tvFirstName);
- TextView middle = (TextView) view.findViewById(R.id.tvMiddleName);
- TextView ss = (TextView) view.findViewById(R.id.tvSS);
- Map<String, Object> mperson = new HashMap<String, Object>();
- mperson = people.get(position);
- dl.setText(mperson.getString("dl"));
- }
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement