Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyAppAdapter extends BaseAdapter //has a class viewholder which holds
- {
- public class ViewHolder
- {
- TextView textName;
- ImageView imageView;
- }
- public List<ClassListItems> parkingList;
- public Context context;
- ArrayList<ClassListItems> arraylist;
- private MyAppAdapter(List<ClassListItems> apps, Context context)
- {
- this.parkingList = apps;
- this.context = context;
- arraylist = new ArrayList<ClassListItems>();
- arraylist.addAll(parkingList);
- }
- @Override
- public int getCount() {
- return parkingList.size();
- }
- @Override
- public Object getItem(int position) {
- return position;
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @SuppressLint("SetTextI18n")
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) // inflating the layout and initializing widgets
- {
- View rowView = convertView;
- ViewHolder viewHolder= null;
- if (rowView == null)
- {
- LayoutInflater inflater = getLayoutInflater();
- rowView = inflater.inflate(R.layout.list_content, parent, false);
- viewHolder = new ViewHolder();
- viewHolder.textName = (TextView) rowView.findViewById(R.id.textName);
- viewHolder.imageView = (ImageView) rowView.findViewById(R.id.imageView);
- rowView.setTag(viewHolder);
- }
- else
- {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- // here setting up names and images
- viewHolder.textName.setText(parkingList.get(position).getName()+"");
- return rowView;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment