开发者

Two expandable list view in the same activity

I have two relative layout in the same activity (for a 3d flip animation) that I rotate between them using a button. Each layout contains an expandable list view that has its own adapter (and custom layout), i've noticed that once an expanadable list view is created the second exp. list view does not catch the onclick event but rather the first exp. list view that was displayed.

I've tried adding an expand listener to each of the listviews (OnGroupExpandListener) but although I stopped at the correct breakpoint each time, the expansion of the group itself did not occur in the current expandable list that was shown to the user.

Could you please help me out?

Thanks!

added my code:

firstList = (ExpandableListView)findViewById(R.id.firstList);
firstList.setOnChildClickListener(listItemClick);
firstList.setOnGroupExpandListener(listFirstGroupClick);


private OnGroupExpandListener listFirstGroupClick = new OnGroupExpandListener() {

    @Override
    public void onGroupExpand(int groupPosition) {
        String correlationid =   
                          (String)listViewAdapter.getGroup(groupPosition);
        try {
              secondList =   
                               (ListView)findViewById(R.id.lstSecond);
            listSecondViewAdapter = new 
                                 SecondListAdapter(getBaseContext(), correlationid);
            secondList.setAdapter(listSecondViewAdapter );
                            //You will notice that both have the same listener 
          开发者_如何学Go                  // its because they perform the same action
                            // but with a changing parameter
                            secondList.setOnChildClickListener(listItemClick)
        } catch (Exception e) {
            e.printStackTrace();
        }
    } 
};

    private OnChildClickListener listItemClick = new OnChildClickListener() {
    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
            int groupPosition, int childPosition, long id) {
        DO SOMETHING...
        return false;
    }
}; 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜