@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if(convertView == null){
LayoutInflater inflater=(LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=inflater.inflate(R.layout.program_list,null);
}
// GET VIEWS
TextView nameTxt=(TextView) convertView.findViewById(R.id.nametxt);
TextView landTxt=(TextView) convertView.findViewById(R.id.landtxt);
TextView groesseTxt=(TextView) convertView.findViewById(R.id.groessetxt);
TextView gewichtTxt=(TextView) convertView.findViewById(R.id.gewichttxt);
ImageView img =(ImageView) convertView.findViewById(R.id.imageView1);
//SET DATA
nameTxt.setText(names[position]);
landTxt.setText(land[position]);
groesseTxt.setText(groesse[position]);
gewichtTxt.setText(gewicht[position]);
img.setImageResource(images[position]);
return convertView;
}
我想创建一个自定义列表视图,并带有onClick到新的Activity ...
调试此代码:
TextView nameTxt=(TextView) convertView.findViewById(R.id.nametxt);
TextView landTxt=(TextView) convertView.findViewById(R.id.landtxt);
TextView groesseTxt=(TextView) convertView.findViewById(R.id.groessetxt);
TextView gewichtTxt=(TextView) convertView.findViewById(R.id.gewichttxt);
ImageView img =(ImageView) convertView.findViewById(R.id.imageView1);
他们的视图(nametxt,landtxt,groessetxt,gewichttxt,imageView1
)可能不在program_list布局中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句