开发学院手机开发Android 开发 Android Listview 详解 阅读

Android Listview 详解

 2010-06-22 02:39:00 来源:WEB开发网   
核心提示:.setTitle("我的listview").setMessage("介绍...").setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void on

.setTitle("我的listview")

.setMessage("介绍...")

.setPositiveButton("确定", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

}

})

.show();

}

public final class ViewHolder{

public ImageView img;

public TextView title;

public TextView info;

public Button viewBtn;

}

public class MyAdapter extends BaseAdapter{

private LayoutInflater mInflater;

public MyAdapter(Context context){

this.mInflater = LayoutInflater.from(context);

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return mData.size();

}

@Override

public Object getItem(int arg0) {

// TODO Auto-generated method stub

return null;

}

@Override

public long getItemId(int arg0) {

// TODO Auto-generated method stub

return 0;

}

@Override

public View getView(int position, View convertView, ViewGroup parent) {

ViewHolder holder = null;

if (convertView == null) {

holder=new ViewHolder();

convertView = mInflater.inflate(R.layout.vlist2, null);

holder.img = (ImageView)convertView.findViewById(R.id.img);

holder.title = (TextView)convertView.findViewById(R.id.title);

holder.info = (TextView)convertView.findViewById(R.id.info);

holder.viewBtn = (Button)convertView.findViewById(R.id.view_btn);

convertView.setTag(holder);

}else {

holder = (ViewHolder)convertView.getTag();

}

holder.img.setBackgroundResource((Integer)mData.get(position).get("img"));

holder.title.setText((String)mData.get(position).get("title"));

上一页  2 3 4 5 6 7 8  下一页

Tags:Android Listview 详解

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接