How to scroll ExpandableListView in properly position when group is clicked
<p>I have a ExpandableListView in my activity that works properly. I set in my adapter a clickListener on RelativeLayout, so when I click on it, my group get expanded. My group list is a ArrayList, my children is a HashMap> where Integer is groupPosition of ArrayList. Children is a comment list that any user can see. The user can add a comment by EditText at end of comment list. My goal is to position at top of screen the groupView clicked. I tried to do this but my problem is:</p>

<p>My first group has 10 comments. If i expand the first group I can see them and the position of my group clicked is right. If I try to expand my fourth group, when the first is already expanded, the ExpandableListView position on my screen goes to the fourth children of first group and not on fourth group just expanded. After if I scroll down the list the fourth group is open, but I would to position on the fourth group and not on fourth children of first group. All works properly if I open only group without comments...</p>

<p>small part of method getGroupView:</p>

<pre><code> scanCommFav=(RelativeLayout)v.findViewById(R.id.feedcell_scancommentfavorite);



scanCommFav.setOnClickListener(new OnClickListener(){

@Override 
                            public void onClick(View v)
                            {
                                if(!isExp)
                                {
                                    if(mess==0)
                                    {
                                        setIdx(idx);
                                        addIndex(idx);
                                        getCommentNoList();

                                    }
                                    else
                                    {
                                        callCommentScript(snapId);

                                        setIdx(idx);
                                        addIndex(idx);
                                    }

                                }
                                else if(isExp)
                                {
                                    setIdx(idx);
                                    removeIndex(idx);
                                    closeGroup(idx);


                                }
                            }
                        });
</code></pre>

<p>addIndex(idx) and removeIndex, add and remove in LinkedList the position of groups open. setIdx(idx) set to int variable the group position that I use for different purpose.</p>

<p>this is openGroup():</p>

<pre><code>private void openGroup(int pos)
{
    feedlistView.setSelectedGroup(pos);
}
</code></pre>

<p>this is closeGroup():</p>

<pre><code>private void closeGroup(int idx)
{
    feedlistView.collapseGroup(idx);
}
</code></pre>

<p>this is my listener:</p>

<pre><code>    feedlistView.setOnItemSelectedListener(new OnItemSelectedListener(){

        @Override
        public void onItemSelected(AdapterView&lt;?&gt; arg0, View view,int position, long id) {
            if(ExpandableListView.getPackedPositionForGroup(position)==ExpandableListView.PACKED_POSITION_TYPE_GROUP)
            {
            int pos = feedlistView.getSelectedItemPosition();
            feedlistView.expandGroup(pos);
            }

        }

        @Override
        public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
            // TODO Auto-generated method stub

        }

    });
</code></pre>

<p>I tried also to implement setOnGroupClickListener but doesn't works. Somebody has any idea?
Thanks</p>
