OK, I did it. I had to get the clickListener outside the IF(convertView == null)
. Now it works right.
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
List<String> child = getChild(groupPosition, childPosition);
String childText = child.get(childPosition);
Button addTag = null;
if(convertView == null) {
LayoutInflater inflater = (LayoutInflater) this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.candidate_list_item, null);
}
if (addTag == null) {
addTag = (Button) convertView.findViewById(R.id.addTag);
}
TextView txtListChild = (TextView) convertView.findViewById(R.id.lblListItem);
txtListChild.setText(childText);
//TODO add button to remove used tags
addTag.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//TODO handle adding tags and add removing tags
StringBuffer tagInfo = new StringBuffer();
//TODO magic with tagMap :D
tagInfo.append("Name: ").append(tagMap.get(connector.get(getGroup(groupPosition))).getName());
tagInfo.append(" GP: ").append(groupPosition);
tagInfo.append(" CP: ").append(childPosition);
tagInfo.append(" CONGET: ").append(connector.get(getGroup(groupPosition)));
Log.i(this.getClass().getCanonicalName(), tagInfo.toString());
}
});
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
StringBuffer tagInfo = new StringBuffer();
//TODO magic with tagMap :D
tagInfo.append("_Name: ").append(tagMap.get(connector.get(getGroup(groupPosition))).getName());
tagInfo.append(" _GP: ").append(groupPosition);
tagInfo.append(" _CP: ").append(childPosition);
tagInfo.append(" _CONGET: ").append(connector.get(getGroup(groupPosition)));
Log.i(this.getClass().getCanonicalName(), tagInfo.toString());
}
});
return convertView;
}
I leave post for others so incompetent as I :)