Advertisement
ua6xh

CirclesArrayAdapter

Oct 2nd, 2013
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. package framework.halpers;
  2.  
  3. import framework.R;
  4.  
  5. import android.content.Context;
  6. import android.util.Log;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.ArrayAdapter;
  11. import android.widget.TextView;
  12.  
  13. import java.util.List;
  14.  
  15. import framework.Models.Circle;
  16.  
  17. public class CirclesArrayAdapter extends ArrayAdapter {
  18.     private static final String TAG = "CirclesArrayAdapter";
  19.     private List<Circle> circles;
  20.     private Context contextAdapter;
  21.  
  22.     public CirclesArrayAdapter(Context context, int textViewResourceId) {
  23.         super(context, textViewResourceId);
  24.         this.contextAdapter = context;
  25.     }
  26.  
  27.     public CirclesArrayAdapter(Context context, List<Circle> circles, int resource) {
  28.         super(context, resource, circles);
  29.         this.circles = circles;
  30.         this.contextAdapter = context;
  31.     }
  32.  
  33.     @Override
  34.     public View getView(int position, View convertView, ViewGroup parent) {
  35.  
  36.         View v = convertView;
  37.  
  38.         if (v == null) {
  39.             LayoutInflater vi;
  40.             vi = LayoutInflater.from(contextAdapter);
  41.             v = vi.inflate(R.layout.circle, null);
  42.         }
  43.  
  44.         Circle p = circles.get(position);
  45.         if (p != null) {
  46.             TextView tt = (TextView) v.findViewById(R.id.id);
  47.             TextView tt1 = (TextView) v.findViewById(R.id.userId);
  48.             TextView tt3 = (TextView) v.findViewById(R.id.name);
  49.  
  50.             if (tt != null) {
  51.                 Log.e(TAG, "id:" + p.id);
  52.                 tt.setText(Integer.toString(p.id));
  53.             }
  54.             if (tt1 != null) {
  55.                 Log.e(TAG, "user_id:" + p.user_id);
  56.                 tt1.setText(Integer.toString(p.user_id));
  57.             }
  58.             if (tt3 != null) {
  59.                 Log.e(TAG, "name:" + p.name);
  60.                 tt3.setText(p.name);
  61.             }
  62.         }
  63.         return v;
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement