Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2015
2,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1.    @Override
  2.     public View getView(int position, View convertView, ViewGroup parent) {
  3.         LocationViewHolderItem viewHolder;
  4.  
  5.         if (convertView == null) {
  6.  
  7.             // inflate the layout
  8.             LayoutInflater inflater = ((Activity) context).getLayoutInflater();
  9.             convertView = inflater.inflate(resourceId, parent, false);
  10.  
  11.             // well set up the ViewHolder
  12.             viewHolder = new LocationViewHolderItem();
  13.             //ID of the TextView in the android.R.layout.simple_list_item_1
  14.             viewHolder.location = (TextView) convertView.findViewById(R.id.activity_register_tv_location_item);
  15.             viewHolder.poweredByGoogle = (ImageView) convertView.findViewById(R.id.activity_register_iv_powered_by_google);
  16.             // store the holder with the view.
  17.             convertView.setTag(viewHolder);
  18.  
  19.         } else {
  20.             // we've just avoided calling findViewById() on resource every time
  21.             // just use the viewHolder
  22.             viewHolder = (LocationViewHolderItem) convertView.getTag();
  23.         }
  24.  
  25.         String location = resultList.get(position);
  26.  
  27.         if (location != null) {
  28.             if (location.equals(FOOTER)) {
  29.                 viewHolder.location.setVisibility(View.GONE);
  30.                 viewHolder.poweredByGoogle.setVisibility(View.VISIBLE);
  31.             } else {
  32.                 viewHolder.poweredByGoogle.setVisibility(View.GONE);
  33.                 viewHolder.location.setVisibility(View.VISIBLE);
  34.                 viewHolder.location.setText(location);
  35.             }
  36.         }
  37.  
  38.         return convertView;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement