Is there a standard way to pin group item to the top of screen while scrolling group\'s items. I saw similar examples with ListView. What interfaces should I implement or wh
I have a really simple solution using AXML and C#. The group will never move and children will be expandable and scrollable.
I'll show you here a case where there is only one group in the list, with the closed state at start.
This solution even works inside scrollviews, viewpagers etc...
In your view, hard code your group view at the top of your ExpandableListView, with LinearLayout or whatever you need (this will never move ;-) ) and set the visibility property of your ExpandableListView to Gone.
Keep using your Adapter, but we have to hide the group view cause we hard coded it in the first step. Just set a LinearLayout with height property to 0dp
Adapter
public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
{
var inflater = _context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
convertView = inflater.Inflate(Resource.Layout.group_visibility_gone, null);
return convertView;
}
AXML template
The event that expand the list is fired by the group we just came to hide.
So let's keep it always open :
expandableListViewNotes.ExpandGroup(0);
Let's create an event by ourslef on the hard coded group
private void llExpandableNotes_Clicked(object sender, EventArgs e)
{
switch(expandableListViewNotes.Visibility)
{
case ViewStates.Gone:
imgExpandable.SetImageResource(Resource.Drawable.icon_minus_red);
txtExapndableNotes.SetTextColor(Android.Graphics.Color.Red);
expandableListViewNotes.Visibility = ViewStates.Visible;
break;
case ViewStates.Visible:
imgExpandable.SetImageResource(Resource.Drawable.icon_plus_black);
txtExapndableNotes.SetTextColor(Android.Graphics.Color.Black);
expandableListViewNotes.Visibility = ViewStates.Gone;
break;
}
}
SUMMARY :
And that's all ! Enjoy !