小编use*_*801的帖子

Expandablelistview子项上的ImageButton

是否可以在Expandablelistview子项上具有可单击的ImageButton?如果是,如何编程其事件监听器?

android expandablelistview

4
推荐指数
1
解决办法
3099
查看次数

折叠或展开时,Android expandablelistview组/父级背景图像会发生变化

我尝试在展开折叠或展开时交换expandablelistview组背景图像.但是背景图像没有正确交换.例如,当我展开第一组时,第二组或第三组的背景会被交换.

我正在使用RelativeLayout(组布局)和SimpleExpandableListAdapter(适配器).这是我做的:

// Create 2 drawable background. One for collapse and one for expand
private Drawable collapseBG, expandBG;
private ExpandableListView myView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    collapseBG = getResources().getDrawable(R.drawable.box_bg_header_collapse);
    expandBG = getResources().getDrawable(R.drawable.box_bg_header_expand);
    myView = (ExpandableListView) findViewById(R.id.myView);
}

myView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
    public void onGroupCollapse(int groupPosition_c) {
        myView.getChildAt(groupPosition_c).setBackgroundDrawable(collapseBG);
    }
});

myView.setOnGroupExpandListener (new ExpandableListView.OnGroupExpandListener() {
    public void onGroupExpand(int groupPosition_e) {
        myView.getChildAt(groupPosition_e).setBackgroundDrawable(expandBG);
    }
});
Run Code Online (Sandbox Code Playgroud)

有谁知道如何使这个工作?

android expandablelistview

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×2

expandablelistview ×2