123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package epson.common;
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.TextView;
- import epson.print.C2135R;
- import epson.print.Util.EPLog;
- import java.util.List;
- public class CustomListRowAdapter extends ArrayAdapter<CustomListRow> {
- private static final String TAG = "Hoge";
- private LayoutInflater inflater;
- private List<CustomListRow> items;
- private View.OnClickListener listener;
- private int resourceId;
- public CustomListRowAdapter(Context context, int i, List<CustomListRow> list) {
- this(context, i, list, (View.OnClickListener) null);
- }
- public CustomListRowAdapter(Context context, int i, List<CustomListRow> list, View.OnClickListener onClickListener) {
- super(context, i, list);
- this.resourceId = i;
- this.items = list;
- this.inflater = (LayoutInflater) context.getSystemService("layout_inflater");
- this.listener = onClickListener;
- }
- public View getView(int i, View view, ViewGroup viewGroup) {
- if (view == null) {
- view = this.inflater.inflate(this.resourceId, (ViewGroup) null);
- }
- return populateView(i, view, viewGroup);
- }
- protected View populateView(int i, View view, ViewGroup viewGroup) {
- EPLog.m305d(TAG, "View position [" + i + "]");
- CustomListRow customListRow = this.items.get(i);
- if (customListRow.getPrefixImageId() != null) {
- ((ImageView) view.findViewById(R.C2137id.row_prefix_image)).setImageResource(customListRow.getPrefixImageId().intValue());
- }
- if (customListRow.getSuffixImageId() != null) {
- ((ImageView) view.findViewById(R.C2137id.row_suffix_image)).setImageResource(customListRow.getSuffixImageId().intValue());
- }
- LinearLayout linearLayout = (LinearLayout) view.findViewById(R.C2137id.row_list_area);
- linearLayout.removeAllViews();
- int sieze = customListRow.sieze();
- for (int i2 = 0; i2 < sieze; i2++) {
- TextView textView = new TextView(viewGroup.getContext());
- textView.setText(customListRow.getText(i2));
- if (customListRow.getTextSize(i2) > 1.0f) {
- textView.setTextSize(customListRow.getTextSize(i2));
- }
- linearLayout.addView(textView, i2);
- }
- View.OnClickListener onClickListener = this.listener;
- if (onClickListener != null) {
- view.setOnClickListener(onClickListener);
- }
- return view;
- }
- public void addList(CustomListRow customListRow) {
- this.items.add(customListRow);
- }
- public void setList(int i, CustomListRow customListRow) {
- this.items.set(i, customListRow);
- }
- }
|