Tôi có một ArrayAdapter đơn giản. Tôi muốn thiết lập trình lắng nghe cho mỗi lần nhấp vào hàng của danh sách của tôi sao cho Hoạt động mới mở ra. Tôi sẽ làm như thế nào? đang ArrayAdapter My -Android - cách thêm phương thức nhấp vào mục vào ArrayAdapter
public class CountryListAdapter extends ArrayAdapter<String> {
private final Activity context;
private final ArrayList<String> names;
public CountryListAdapter(Activity context, ArrayList<String> names) {
super(context, R.layout.rowlayout, names);
this.context = context;
this.names = names;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.rowlayout, null, true);
TextView textView = (TextView) rowView.findViewById(R.id.label);
textView.setText(names.get(position));
return rowView;
}
Có cách nào để ràng buộc logic onClick vào ArrayAdapter (hoặc bất kỳ bộ điều hợp nào khác) không? Tôi có một bộ chuyển đổi, nhưng ListViews nhiều, được lấp đầy với nó, và nó sẽ là đẹp hơn để ràng buộc nó vào Adapter chính nó? –