1.xml文件中,android:weight 权重
计算为
计算得出= ( if fillParent or matchParent, parentWidth or parentHeight) (if wrapContent,显示全部内容的width or height)
实际所需=计算得出 + 权重比例*剩余空间
2.listActivity若要用自定义布局, xml布局必须有一个listView,而且id为android:id="@android:id/list",否则运行不起来
3.getView()中,写法,与iOS cellForRow:相近
LinearLayout extends viewGroup
viewGroup extends View
LinearLayout ll = null;
if (convertView != null) {
ll = (LinearLayout) convertView;
}else {
//通过读取xml文件得到layout
ll = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.custom_listcell, null);
}
ImageView imgView = (ImageView) ll.findViewById(R.id.icon);
TextView name = (TextView) ll.findViewById(R.id.name);
TextView dec = (TextView) ll.findViewById(R.id.dec);
CustomListCellData data = (CustomListCellData)getItem(position);
name.setText(data.name);
dec.setText(data.dec);
imgView.setImageResource(data.iconId);
return ll;