Back to project page interamap.
The source code is released under:
MIT License
If you think the Android project interamap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.richso.interamap.adapter; /*from www .j a v a2 s. com*/ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import com.richso.interamap.MoreInfoScreen; import com.richso.interamap.R; import com.richso.interamap.item.ItemCategory; import java.util.ArrayList; /** * Created with IntelliJ IDEA. * User: nikolai * Date: 9/15/13 * Time: 1:59 PM * To change this template use File | Settings | File Templates. */ public class CategoryAdapter extends ArrayAdapter<ItemCategory> { private Context context; private int layoutResourceId; private ArrayList<ItemCategory> data = new ArrayList<ItemCategory>(); public CategoryAdapter(Context context, int textViewResourceId, ArrayList<ItemCategory> data) { super(context, textViewResourceId, data); this.context = context; this.layoutResourceId = textViewResourceId; this.data = data; } @Override public ItemCategory getItem(int position) { return super.getItem(position); } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; RecordHolder holder = null; if ( row == null ) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new RecordHolder(); holder.txtTitle = (TextView) row.findViewById(R.id.itemCategotyTitle); holder.txtDistance = (TextView)row.findViewById(R.id.itemCategoryDistance); ImageView imageView = (ImageView) row.findViewById(R.id.itemCategoryIcon); Button btnMoreInfo = (Button)row.findViewById(R.id.itemCategoryBtnMoreInfo); btnMoreInfo.setOnClickListener(moreInfoListener); holder.imageItem = imageView; row.setTag(holder); } else { holder = (RecordHolder) row.getTag(); } ItemCategory item = data.get(position); holder.txtTitle.setText(item.getTitle()); holder.txtDistance.setText(item.getDistance()+""); holder.imageItem.setImageBitmap(item.getIcon()); return row; } View.OnClickListener moreInfoListener = new View.OnClickListener() { @Override public void onClick(View v) { openMoreInfoScreen(); } }; private void openMoreInfoScreen() { Intent intent = new Intent(context, MoreInfoScreen.class); // intent.putExtra(Constant.Extra.itemCategoryTitle, ); context.startActivity(intent); } static class RecordHolder { TextView txtTitle; TextView txtDistance; ImageView imageItem; } }