Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Code:
  2. ..
  3. public static ListView listView;
  4. public static MySKUArrayAdapter adapter;
  5. public static ArrayList<String> name = new ArrayList<String>();
  6. public static ArrayList<String> number = new ArrayList<String>();
  7.  
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main);
  12.  
  13. listView = (ListView) findViewById(R.id.list);
  14. name.clear();
  15. number.clear();
  16. name.add("name1");
  17. name.add("name2");
  18.  
  19. number.add("11111");
  20. number.add("22222");
  21.  
  22. adapter = new MyArrayAdapter(this, name, number);
  23. listView.setAdapter(adapter);
  24.  
  25. }
  26.  
  27. MyArrayAdapter:
  28. @Override
  29. public View getView(final int position, View convertView, ViewGroup parent) {
  30.  
  31. View rowView;
  32. LayoutInflater inflater = (LayoutInflater) context
  33. .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  34. if (position == getCount() - 1) {
  35.  
  36. rowView = inflater.inflate(R.layout.custom_view, parent, false);
  37.  
  38. } else {
  39. rowView = inflater.inflate(R.layout.row_add, parent, false);
  40. TextView NAME = (TextView) rowView.findViewById(R.id.name);
  41. TextView PHONE = (TextView) rowView.findViewById(R.id.phone);
  42.  
  43. NAME.setText(mName[position]);
  44. PHONE.setText(mPhone[position]);
  45. }
  46.  
  47. return rowView;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement