Variable groupPosition is accessed from within inner class,needs to be declared final.
繼承一下
class MyClickListener implements View.OnClickListener {
private int groupPosition;
private int childPosition;
public MyClickListener(int groupPosition,int childPosition){
this.groupPosition = groupPosition;
this.childPosition = childPosition;
}
public void onClick(View v) {
System.out.println(this.groupPosition);
System.out.println(this.childPosition);
}
}
然後
childImage.setOnClickListener(new MyClickListener(groupPosition,childPosition));