Created
December 23, 2014 17:06
-
-
Save pratamawijaya/b86f5ea48e3e6ff13c8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.wisatajogja; | |
import java.util.List; | |
import com.nostra13.universalimageloader.core.ImageLoader; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
public class MyAdapter extends BaseAdapter | |
{ | |
static class Holder | |
{ | |
TextView title, detail; | |
ImageView thumb; | |
} | |
private List<E_Lokasi> listLokasi; | |
private LayoutInflater inflater; | |
private ImageLoader imageLoader; | |
// edit | |
private Context context; | |
public MyAdapter(Context context, List<E_Lokasi> listLokasi, | |
ImageLoader imageLoader) | |
{ | |
this.listLokasi = listLokasi; | |
this.imageLoader = imageLoader; | |
inflater = LayoutInflater.from(context); | |
// edit | |
this.context = context; | |
} | |
@Override | |
public int getCount() | |
{ | |
// TODO Auto-generated method stub | |
return listLokasi.size(); | |
} | |
@Override | |
public Object getItem(int position) | |
{ | |
// TODO Auto-generated method stub | |
return listLokasi.get(position); | |
} | |
@Override | |
public long getItemId(int position) | |
{ | |
// TODO Auto-generated method stub | |
return 0; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) | |
{ | |
Holder holder; | |
if (convertView == null) | |
{ | |
convertView = inflater.inflate(R.layout.single_row, null); | |
holder = new Holder(); | |
holder.title = (TextView) convertView.findViewById(R.id.titleRow); | |
holder.detail = (TextView) convertView.findViewById(R.id.detailRow); | |
holder.thumb = (ImageView) convertView.findViewById(R.id.thumbRow); | |
convertView.setTag(holder); | |
} else | |
{ | |
holder = (Holder) convertView.getTag(); | |
} | |
holder.title.setText(listLokasi.get(position).getNama()); | |
holder.detail.setText(listLokasi.get(position).getAlamat()); | |
// imageLoader.displayImage(listLokasi.get(position).getGambar(), | |
// holder.thumb, ImageUtils.getImgOpt()); | |
// edit | |
Picasso.with(context).load(listLokasi.get(position).getGambar()).into(holder.thumb); | |
return convertView; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment