开发者

Expandable list view change default behaviour

开发者 https://www.devze.com 2023-03-17 10:27 出处:网络
I would like to change the default behaviour of the expandable list view from: short click => expand / collapse

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

精彩评论

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