package com.vanceinfo.iwom.foraging.view;
import java.util.ArrayList;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.vanceinfo.iwom.foraging.activity.R;
public class MoreRegionsViewAdapter extends BaseAdapter {
private static final String TAG = "MoreRegionsViewAdapter";
private ArrayList<String> mArrayList = null;
private Context mContext = null;
private LayoutInflater inflater = null;
public MoreRegionsViewAdapter(){}
public MoreRegionsViewAdapter(Context context, ArrayList<String> arrayList) {
mArrayList = arrayList;
mContext = context;
inflater = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
if(mArrayList.size() < 0) {
return -1;
} else {
return mArrayList.size();
}
}
@Override
public Object getItem(int position) {
if(position<0||position>mArrayList.size()) {
return null;
}
return mArrayList.get(position);
}
@Override
public long getItemId(int position) {
if(position < 0 || position > mArrayList.size()) {
return -1;
} else {
return position;
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_view_on_search_activity_more_item, null);
holder = new ViewHolder();
holder.textview = (TextView) convertView.findViewById(R.id.id_for_search_activity_more_item);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.textview.setText(mArrayList.get(position));
Log.v(TAG, "rating bar : " + mArrayList.get(position));
convertView.setTag(holder);
return convertView;
}
protected class ViewHolder {
TextView textview;
}
}