Andorid學習記錄

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;



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章