Guest User

customadapter

a guest
Feb 3rd, 2012
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. public class Adapter extends BaseAdapter{
  2.    
  3.     private static LayoutInflater inflater=null;
  4.     private static String [] placename;
  5.    
  6.     @SuppressWarnings("static-access")
  7.     public StayAdapter(Activity a, String [] placename)
  8.     {
  9.         this.placename = placename;
  10.         inflater = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  11.     }
  12.     @Override
  13.     public int getCount() {
  14.         // TODO Auto-generated method stub
  15.         return placename.length;
  16.     }
  17.  
  18.     @Override
  19.     public Object getItem(int position) {
  20.         // TODO Auto-generated method stub
  21.         return position;
  22.     }
  23.  
  24.     @Override
  25.     public long getItemId(int position) {
  26.         // TODO Auto-generated method stub
  27.         return position;
  28.     }
  29.  
  30.     @Override
  31.     public View getView(int position, View convertView, ViewGroup parent) {
  32.         // TODO Auto-generated method stub
  33.         View vi=convertView;
  34.         if(convertView==null)
  35.             vi = inflater.inflate(R.layout.staylist, null);
  36.        
  37.         TextView namee = (TextView)vi.findViewById(R.id.name);
  38.         namee.setText(placename[position]);
  39.        
  40.         int height = convertView.getHeight();[Null pointer exception here]
  41.        
  42.         return vi;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment