In my expandablelistview some have children and some doesn't. GroupView's which have no children contain a Textview and a Button. On clicking the button, i need to pass the textview's data to next activity through intent. Now my problem is, i can't able to set the onclick event on groupview's button which has no child and i also need the groupPosition.
Here is my clickListener code in main java file:
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
switch (groupPosition) {
case 0:
Log.d(">>>", "" + groupPosition);
break;
case 1:
Log.d(">>>", "" + groupPosition);
break;
case 2:
Log.d(">>>", "" + groupPosition);
break;
case 3:
Log.d(">>>", "" + groupPosition);
break;
}
return false;
}
});
Here is my adapter code:
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
groupIndex = groupPosition;
QuotedListGroup group = (QuotedListGroup) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater inf = (LayoutInflater) context
.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = inf.inflate(R.layout.activity_expandable_listview, null);
}
if(groupPosition%2 == 0) {
convertView.findViewById(R.id.part_1).setVisibility(View.VISIBLE);
convertView.findViewById(R.id.part_2).setVisibility(View.GONE);
//Other code..
} else {
convertView.findViewById(R.id.part_1).setVisibility(View.GONE);
convertView.findViewById(R.id.part_2).setVisibility(View.VISIBLE);
//Other code..
}
return convertView;
}
Actually, i need to show two different layouts for even numbered and odd numbered groups in the same expandablelistview.
Any help you can provide is greatly appreciated!