开发者

Expandable list view change default behaviour

I would like to change the default behaviour of the expandable list view from:

short click => expand / collapse

to:

开发者_如何学Python
long click => expand / collapse    
short click => select item or child


OK, it seems the best solution is to do this with a list item click / long click listener.

public void onClick(View view)
{
    // click - do something with item       
}

public boolean onLongClick(View view)
{
    // group position was stored in view tag
    int groupPosition = (Integer) view.getTag();

    ExpandableListView listView = (ExpandableListView) findViewById(R.id.expandableListView);
    if (listView.isGroupExpanded(groupPosition))
        listView.collapseGroup(groupPosition);
    else
        listView.expandGroup(groupPosition);

    return true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜