I'm stuck with creating custom adapter. I want to setOnClickListener on the buttons inside ListView and I found this topic which looks ok how-to-setonclicklistener-on-the-button-inside-the-listview but the problem is that I'm getting unreachable code error on the getLayoutInflater line.
here is my code
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;
}
}
both methods doesn't work for me
LayoutInflater inflater = context.getLayoutInflater();
and
LayoutInflater li = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);