Tôi đang mắc kẹt với việc tạo bộ điều hợp tùy chỉnh. Tôi muốn setOnClickListener trên các nút bên trong ListView và tôi tìm thấy chủ đề này trông ok how-to-setonclicklistener-on-the-button-inside-the-listview nhưng vấn đề là tôi nhận được lỗi mã không thể truy cập trên dòng getLayoutInflater.getLayoutInflater bên trong tùy chỉnh simpleCursorAdapter
đây là mã của tôi
public class MyCursorAdapter extends SimpleCursorAdapter{
private final Context ctx;
private Button tagButton = null;
public MyCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
ctx = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return super.getView(position, convertView, parent);
LayoutInflater li = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = li.inflate(R.layout.tags_list_element, null, true);
tagButton= (Button)rowView.findViewById(R.id.tag_title);
tagButton.setTag(position);
tagButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
return rowView;
}
}
cả hai phương pháp không làm việc cho tôi
LayoutInflater inflater = context.getLayoutInflater();
và
LayoutInflater li = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Can u plz cho tôi lỗi Log ........... – c2dm