android仿天猫精品页列表界面WIN8风格列表Listview实现
即将做的项目需要弄天猫的这个效果,于是做了本DEMO。。。。。本代码仿天猫ANDROID客户端,精品页面的列表界面,为了提高开发效率,本代码使用了Afinal框架,用于加载网络图片,为了节省时间,使用了普通的LISTVIEW实现,后续大家可用支持下拉刷新,上拉更多的列表组件替代。本代码绝对可运行。代码编码UTF-8。。。。。
核心代码:
package android88.app.listview.demo.adapter; import java.util.List; import net.tsz.afinal.FinalBitmap; import android.R.integer; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android88.app.listview.demo.R; public class Win8ListAdapter extends BaseAdapter { List<String> _ImgsURL; int _ItemCountNumber; // 列表总条数 int _AItemShowImgNumber = 3; // 列表每条显示图片数 Context _Context; FinalBitmap _FinalBitmap; public Win8ListAdapter(Context context, List<String> imgsURL) { _Context = context; _ImgsURL = imgsURL; if (imgsURL.size() % _AItemShowImgNumber == 0) { _ItemCountNumber = imgsURL.size() / _AItemShowImgNumber; } else { _ItemCountNumber = imgsURL.size() / _AItemShowImgNumber + 1; } _FinalBitmap = FinalBitmap.create(_Context);// 初始化FinalBitmap模块 } @Override public int getCount() { return _ItemCountNumber; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return position; } static class ViewHold { ImageView subImageView1; ImageView subImageView2; ImageView subImageView3; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHold _ViewHold = new ViewHold(); if (position % 2 == 0) { convertView = LayoutInflater.from(_Context).inflate( R.layout.item_one, null); } else { convertView = LayoutInflater.from(_Context).inflate( R.layout.item_two, null); } _ViewHold.subImageView1 = (ImageView) convertView .findViewById(R.id.subItem1); _ViewHold.subImageView2 = (ImageView) convertView .findViewById(R.id.subItem2); _ViewHold.subImageView3 = (ImageView) convertView .findViewById(R.id.subItem3); for (int i = 0; i < _AItemShowImgNumber; i++) { int index = position * _AItemShowImgNumber + i; if (index >= _ImgsURL.size()) { break; } else { if (i == 0) { _ViewHold.subImageView1.setVisibility(View.VISIBLE); _FinalBitmap.display(_ViewHold.subImageView1, _ImgsURL.get(index)); } else if (i == 1) { _ViewHold.subImageView2.setVisibility(View.VISIBLE); _FinalBitmap.display(_ViewHold.subImageView2, _ImgsURL.get(index)); } else if (i == 2) { _ViewHold.subImageView3.setVisibility(View.VISIBLE); _FinalBitmap.display(_ViewHold.subImageView3, _ImgsURL.get(index)); } } } return convertView; } }
代码下载地址:
http://download.csdn.net/detail/java886o/6201613
代码运行效果: