Andorid学习记录

来源:互联网 发布:mac照片分类管理软件 编辑:程序博客网 时间:2024/06/05 19:36

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;



0 0
原创粉丝点击