public class ImageAndTextListAdapter extends ArrayAdapter<ImageAndText> {
// new method
private ListView listView;
private AsyncImageLoader asyncImageLoader;
private ImageAndText imageAndText;
//constructor
public ImageAndTextListAdapter(Activity activity, List<ImageAndText> imageAndTexts) {
super(activity, 0, imageAndTexts);
asyncImageLoader = new AsyncImageLoader();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Activity activity = (Activity) getContext();
////////////////////////////////////////////////////////////////////////////////////////////////
// Load the image and set it on the ImageView
//new method
// Inflate the views from XML
View rowView = convertView;
ViewCache viewCache;
if (rowView == null) {
LayoutInflater inflater = activity.getLayoutInflater();
rowView = inflater.inflate(R.layout.image_and_text_row, null);
viewCache = new ViewCache(rowView);
rowView.setTag(viewCache);
} else {
viewCache = (ViewCache) rowView.getTag();
}
imageAndText = getItem(position);
Button btn2=(Button) findViewById(R.id.button1);
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//...........
}
});
该校对《名单》进行校正,采用图像_和_text_row.xml,这些图像代表了名单上的浏览数据。 节目在我点击听众时坠毁。 如果听众被删除,那么该方案就会被罚款。
the question is why the adapter cannot have a button click listener inside the code?