Reputation: 32680
I'm using an ExpandableListView widget. When a group view is clicked, in addition to displaying the child views, I also want to make a change to the group view. I have added an OnClickListener to the group views in the adapter's getGroupView() method, but when one of them is clicked, the changes to the group view are made but the child views don't display - it's as if the OnClickListener overrides the showing of the child views. Is there a call I can add to the OnClickListener to display the children? Any other thoughts are welcome...
EDIT: Here is the code for the getGroupView() method, with the OnClickListener added. I don't think any of the other code is relevant given that it works fine when the OnClickListener is commented out
@Override
public View getGroupView(int position, boolean arg1, View convertView,
ViewGroup arg3) {
if (convertView == null){
convertView = getLayoutInflater().inflate(R.layout.questionbox, null);
}
TextView summary = (TextView)convertView.findViewById(R.id.questionHl);
final TextView asker = (TextView)convertView.findViewById(R.id.asker);
TextView numviews = (TextView)convertView.findViewById(R.id.numViews);
TextView numAnswers = (TextView)convertView.findViewById(R.id.numAnswers);
final TextView fullText = (TextView)convertView.findViewById(R.id.fullText);
summary.setText(q.get(position).summary);
asker.setText("by " + q.get(position).author);
numviews.setText(Integer.toString(q.get(position).views));
numAnswers.setText(Integer.toString(q.get(position).numAnswers));
fullText.setText(q.get(position).fullText);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (fullText.getVisibility() == 8){
fullText.setVisibility(1);;
}
else if (fullText.getVisibility() == 0){
fullText.setVisibility(8);
}
}
});
return convertView;
}
Upvotes: 1
Views: 1934
Reputation: 2981
I think it's because your onclicklistener returns true when it should return false. True means that you fully handled the event, so then it is not forwarded back to the expandable list view. But I'm taking a blind guess here, since you didn't show any code :D
Edit: Some onclick methods return a boolean, some don't, so I might be completely wrong. Could you show us your code?
Upvotes: 6