12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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.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);
- resourceId = i;
- items = list;
- inflater = (LayoutInflater) context.getSystemService("layout_inflater");
- listener = onClickListener;
- }
- public View getView(int i, View view, ViewGroup viewGroup) {
- if (view == null) {
- view = inflater.inflate(this.resourceId, (ViewGroup) null);
- }
- return populateView(i, view, viewGroup);
- }
- protected View populateView(int i, View view, ViewGroup viewGroup) {
- EPLog.d(TAG, "View position [" + i + "]");
- CustomListRow customListRow = items.get(i);
- if (customListRow.getPrefixImageId() != null) {
- ((ImageView) view.findViewById(R.id.row_prefix_image)).setImageResource(customListRow.getPrefixImageId().intValue());
- }
- if (customListRow.getSuffixImageId() != null) {
- ((ImageView) view.findViewById(R.id.row_suffix_image)).setImageResource(customListRow.getSuffixImageId().intValue());
- }
- LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.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 = listener;
- if (onClickListener != null) {
- view.setOnClickListener(onClickListener);
- }
- return view;
- }
- public void addList(CustomListRow customListRow) {
- items.add(customListRow);
- }
- public void setList(int i, CustomListRow customListRow) {
- items.set(i, customListRow);
- }
- }
|