here is my custom adapter.
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row=inflater.inflate(R.layout.single_row, parent, false);
ImageView myImage= (ImageView) row.findViewById(R.id.imageView);
TextView myNames= (TextView) row.findViewById(R.id.contact_name);
TextView myNumbers= (TextView) row.findViewById(R.id.contact_num);
Button btn= (Button) row.findViewById(R.id.caller_button);
myImage.setImageResource(images[position]);
myNames.setText(nameArray[position]);
myNumbers.setText(numberArray[position]);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
return row;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…