更新时间:2015年12月28日15时05分 来源:传智播客Android培训学院 浏览次数:
<LinearLayout orientation="vertical">
<ImageView/>
<TextView/>
</LinearLayout>
<TextView drawableBottom="@drawable/contact"/>
<LinearLayout orientation="horizontal">
<ImageView/>
<LinearLayout orientation="vertical">
<LinearLayout orientation="horizontal">
<TextView/>
<TextView/>
</LinearLayout>
<TextView/>
<LinearLayout orientation="horizontal">
<TextView/>
<TextView/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout>
<Image id=avatar layout_alignParentLeft=true />
<TextView id=name layout_alignParentTop=true layout_toRightOf=@id/avatar />
<TextView id=location layout_alignParentTop=true layout_toRightOf=@id/name />
<TextView id=desc layout_below=@id/location layout_toRightOf=@id/avatar />
....
</RelativeLayout>
<LinearLayout orientation="vertical">
......
<include layout="@layout/include_view_layout"/>
......
</LinearLayout>
而
include_view_layout.xml
的代码如下:
<LinearLayout orientation="vertical">
<Button/>
<Button/>
</LinearLayout>
<LinearLayout orientation="vertical">
<LinearLayout orientation="vertical">
<Button/>
<Button/>
</LinearLayout>
</LinearLayout>
<merge>
<Button/>
<Button/>
</merge>
viewstub2
"
ViewStub stub1 = (ViewStub) findViewById(R.id.viewstub1);
ViewStub stub2 = (ViewStub) findViewById(R.id.viewstub2);
if(isLogin()) {
stub1.inflate();
} else {
stub2.inflate();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyItem product = list.get(position);
convertView = getLayoutInflater()
.inflate(R.layout.item_record, null);
TextView tvDate = (TextView) convertView
.findViewById(R.id.tvDate);
TextView tvYongtu = (TextView) convertView
.findViewById(R.id.tvYongtu);
TextView tvMoney = (TextView) convertView
.findViewById(R.id.tvMoney);
tvDate.setText(product.detaildate);
tvYongtu.setText(product.auditmessage);
tvMoney.setText(product.detailmoney);
return convertView;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyItem product = list.get(position);
ViewHolder holder;
if (convertView == null) {
convertView = getLayoutInflater().inflate(
R.layout.item_record, null);
holder = new ViewHolder();
holder.tvDate = (TextView) convertView
.findViewById(R.id.tvDate);
holder.tvYongtu = (TextView) convertView
.findViewById(R.id.tvYongtu);
holder.tvMoney = (TextView) convertView
.findViewById(R.id.tvMoney);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tvDate.setText(product.detaildate);
holder.tvYongtu.setText(product.auditmessage);
holder.tvMoney.setText(product.detailmoney);
return convertView;
}
static class ViewHolder {
TextView tvDate;
TextView tvYongtu;
TextView tvMoney;
}