How can 开发者_JAVA百科I accomplish this without extending BaseAdapter
?
final int count = array.size();
/* layout to draw list */
LinearLayout list = (LinearLayout) findViewById(R.id.list);
LayoutInflater mInflater = null;
mInflater = LayoutInflater.from(this);
for (int i = 0; i < count; i++) {
/* row of the list - XML File */
View convertView = mInflater.inflate(R.layout.item_list, null);
/* holder class to hold row information to display on screen */
Holder holder = new Holder();
convertView.setId(array.get(i).getId());
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
holder.iconName = (TextView) convertView.findViewById(R.id.name);
holder.msg = (TextView) convertView.findViewById(R.id.msg);
convertView.setTag(holder);
RelativeLayout.LayoutParams parms = new RelativeLayout.LayoutParams(48, 48);
holder.icon.setLayoutParams(parms);
holder.iconName.setText( " your code " );
holder.msg.setText(" your message ");
/* add row to the list */
list.addView(convertView);
convertView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/* show details */
showDetails(v.getId());
}
});
}
精彩评论