kjromero

Adpter base adapter

Jun 11th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. public class ItemAdapter extends BaseAdapter {
  2.  
  3.     private Context context;
  4.     private String[] items;
  5.  
  6.     public ItemAdapter(Context context, String[] items) {
  7.         this.context = context;
  8.         this.items = items;
  9.     }
  10.  
  11.     @Override
  12.     public int getCount() {
  13.         return 0;
  14.     }
  15.  
  16.     @Override
  17.     public Object getItem(int position) {
  18.         return null;
  19.     }
  20.  
  21.     @Override
  22.     public long getItemId(int position) {
  23.         return 0;
  24.     }
  25.  
  26.     @Override
  27.     public View getView(int position, View convertView, ViewGroup parent) {
  28.  
  29.         View v = convertView;
  30.  
  31.         if (convertView == null){
  32.             //Create a new view into  the list
  33.             LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  34.             v = inflater.inflate(R.layout.list_item, parent, false);
  35.         }
  36.  
  37.         TextView category = (TextView)v.findViewById(R.id.category);
  38.  
  39.         String item = this.items[position];
  40.         category.setText(item);
  41.  
  42.         return v;
  43.     }
  44. }
Add Comment
Please, Sign In to add comment