Note that there are some explanatory texts on larger screens.

plurals
  1. POGeneric adapter for many kinds of listview 's layout row in android
    primarykey
    data
    text
    <p>For each list view with difference row layout template, I must create each custom adapter, which do the same thing: load xml row layout, get control (TextView, ImageView, etc..) by id, display data... something like this:</p> <pre><code>public class CommentAdapter extends BaseAdapter { protected Activity activity; protected static LayoutInflater layoutInflater = null; protected List&lt;Comment&gt; lst; public CommentAdapter(Activity activity, List&lt;Comment&gt; lst){ this.activity = activity; this.lst = lst; layoutInflater = (LayoutInflater)this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { return lst.size(); } public Object getItem(int position) { return lst.get(position); } public long getItemId(int position) { return position; } public static class ViewHolder{ public TextView textName; public TextView textComment; public ImageView image; } public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; ViewHolder viewHolder; if (v == null) { v = layoutInflater.inflate(R.layout.listitem, null); viewHolder = new ViewHolder(); viewHolder.textName = (TextView) v.findViewById(R.id.txtName); viewHolder.image = (ImageView) v.findViewById(R.id.icon); viewHolder.textComment = (TextView)v.findViewById(R.id.txtComment); v.setTag(viewHolder); } else { viewHolder = (ViewHolder) v.getTag(); } Static.overrideFonts(v); viewHolder.image.setBackgroundResource(lst.get(position).Icon); viewHolder.textName.setText(lst.get(position).Name); viewHolder.textComment.setText(lst.get(position).Comment); return v; } } </code></pre> <p>With many kind of list view (difference row layout template), I have to create many adapters. <br> So, the question is that I want to create one template adapter, which can be dynamic load row xml, map view control base on its id (maybe use reflect). The row xml layout, the control id, view control will be defined in another places.<br> Is there any <code>design pattern</code>, <code>example</code> or <code>framework</code> can achieve this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload