我有一個自定義適配器類的列表視圖。每個列表項目包含2個文本視圖和一個按鈕。我想獲得那些文本視圖的數據,而我點擊按鈕列表中。如何從按鈕點擊從列表視圖獲取textviews的價值?
下面是列表視圖的演示模式
請幫我傢伙
@Override
public View getView(int position, View convertView, ViewGroup parent) {
IconView icon;
TextView title;
TextView description;
Button favour;
if (convertView == null) {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(textViewResourceId, parent, false);
}
icon = (IconView) convertView.findViewById(R.id.station_icon);
title = (TextView) convertView.findViewById(R.id.station_title);
description = (TextView) convertView.findViewById(R.id.station_description);
favour=(Button)convertView.findViewById(R.id.favbutton);
Station station = getItem(position);
convertView.setTag(station);
title.setText(station.title);
icon.setIcon(station.thumb);
description.setText(station.description);
return convertView;
}
}
只需獲取返回的視圖並根據id或類型獲取子視圖,而不是從中讀取文本。 – 2014-09-03 12:56:56