@@ -0,0 +1,2012 @@
+package com.launch_pad.dixie.launch_pad_lists;%0A%0Aimport android.content.Context;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.widget.BaseAdapter;%0Aimport android.widget.ImageView;%0Aimport android.widget.TextView;%0A%0Aimport java.util.ArrayList;%0A%0A/**%0A * Created by bradc on 3/22/16.%0A */%0Apublic class StatesListAdapter extends BaseAdapter%0A%7B%0A%09private ArrayList%3CString%3E mRows = null;%0A%09private Context mContext = null;%0A%0A%09public StatesListAdapter(Context context, ArrayList%3CString%3E data)%0A%09%7B%0A%09%09super();%0A%0A%09%09mContext = context;%0A%09%09mRows = data;%0A%09%7D%0A%0A%0A%09@Override%0A%09public int getCount()%0A%09%7B%0A%09%09int result = 0;%0A%0A%09%09if (mRows != null)%0A%09%09%7B%0A%09%09%09result = mRows.size();%0A%09%09%7D%0A%0A%09%09return result;%0A%09%7D%0A%0A%09@Override%0A%09public Object getItem(int position)%0A%09%7B%0A%09%09Object result = null;%0A%0A%09%09if (mRows != null && mRows.size() %3E 0 && position %3C mRows.size())%0A%09%09%7B%0A%09%09%09result = mRows.get(position);%0A%09%09%7D%0A%0A%09%09return result;%0A%09%7D%0A%0A%09@Override%0A%09public long getItemId(int position)%0A%09%7B%0A%09%09return position;%0A%09%7D%0A%0A%09@Override%0A%09public View getView(int position, View convertView, ViewGroup parent)%0A%09%7B%0A%09%09ViewHolder holder = null;%0A%0A%09%09// Define the cell%0A%09%09if (convertView == null)%0A%09%09%7B%0A%09%09%09convertView = LayoutInflater.from(mContext).inflate(R.layout.state_list_item, null);%0A%0A%09%09%09holder = new ViewHolder();%0A%09%09%09holder.name = (TextView) convertView.findViewById(R.id.state_name);%0A%09%09%09holder.flag = (ImageView) convertView.findViewById(R.id.state_flag);%0A%0A%09%09%09convertView.setTag(holder);%0A%09%09%7D%0A%09%09else%0A%09%09%7B%0A%09%09%09holder = (ViewHolder) convertView.getTag();%0A%09%09%7D%0A%0A%09%09// Populate values in the cell%0A%09%09String stateName = mRows.get(position);%0A%0A%09%09holder.name.setText(stateName);%0A%0A%09%09String flagName = stateName.toLowerCase() + %22_flag%22;%0A%09%09flagName = flagName.replaceAll(%22 %22, %22_%22);%0A%0A%09%09int resId = mContext.getResources().getIdentifier(flagName, %22drawable%22, mContext.getPackageName());%0A%09%09holder.flag.setBackgroundResource(resId);%0A%0A%09%09return convertView;%0A%09%7D%0A%0A%09private static class ViewHolder%0A%09%7B%0A%09%09public TextView name;%0A%09%09public ImageView flag;%0A%09%7D%0A%7D%0A

add adapter