package mrcToolkit.mobilerelayscontroller; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.ArrayList; public class MyCustomAdapter extends BaseAdapter { private ArrayList mListItems; private LayoutInflater mLayoutInflater; public MyCustomAdapter(Context context, ArrayList arrayList){ mListItems = arrayList; mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { // TODO Auto-generated method stub return mListItems.size(); } @Override public Object getItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int arg0) { // TODO Auto-generated method stub return 0; } @Override public View getView(int arg0, View arg1, ViewGroup arg2) { // TODO Auto-generated method stub if(arg1 == null){ arg1 = mLayoutInflater.inflate(R.layout.list_item, null); } String stringItem = mListItems.get(arg0); if(stringItem != null){ TextView itemName = (TextView) arg1.findViewById(R.id.list_item_text_view); if(itemName != null){ itemName.setText(stringItem); } } return arg1; } }