Advertisement
Guest User

Untitled

a guest
Jan 11th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. package Adapters;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import mci.multipratic.R;
  7.  
  8. import android.content.Context;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.*;
  13.  
  14. public class RecipesAdapter extends BaseAdapter
  15. {
  16.     private LayoutInflater inflater;
  17.     private List<String> data;
  18.    
  19.     public RecipesAdapter(Context context, List<String> data)
  20.     {
  21.         this.inflater = LayoutInflater.from(context);
  22.         this.data = data;
  23.     }
  24.    
  25.     public int getCount()
  26.     {
  27.         return this.data.size();
  28.     }
  29.  
  30.     public String getItem(int position)
  31.     {
  32.         return this.data.get(position);
  33.     }
  34.    
  35.     public long getItemId(int arg0)
  36.     {  
  37.         return 0;
  38.     }
  39.  
  40.     public View getView(int position, View view, ViewGroup parent)
  41.     {
  42.         ViewHolder holder = new ViewHolder();
  43.        
  44.         if(view == null)
  45.         {
  46.             view = inflater.inflate(R.layout.recipe_listview, null);       
  47.             holder.checkBox = (CheckBox) view.findViewById(R.id.checkBoxListView);
  48.             holder.editText = (EditText) view.findViewById(R.id.editTxtListView);          
  49.            
  50.             view.setTag(holder);       
  51.         }else
  52.         {
  53.             holder = (ViewHolder) view.getTag();           
  54.         }
  55.  
  56.         holder.editText.setText(data.get(position));
  57.                
  58.        
  59.         return view;
  60.     }
  61.  
  62.     public static class ViewHolder
  63.     {
  64.         public CheckBox checkBox;
  65.         public EditText editText;  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement