
我正在使用relativeLayout(组布局)和Simpleexpandablelistadapter(适配器).这是我做的:
// Create 2 drawable background. One for collapse and one for expandprivate 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); }}); 有谁知道如何使这个工作?
解决方法 我认为你应该制作自己的适配器,它扩展了Simpleexpandablelistadapter.在那个班级你应该覆盖public VIEw getGroupVIEw(int groupposition,boolean isExpanded,VIEw convertVIEw,VIEwGroup parent) { VIEw result = super.getGroupVIEw(groupposition,isExpanded,convertVIEw,parent); if (isExpanded) { result.setBackgroundDrawable(expandBG); } else { result.setBackgroundDrawable(collapseBG); } return result;} 在onCreate函数中你应该写如下的smth:
myVIEw.setlistadapter (new YourExtendedSimpleexpandablelistadapter( ...... ));
希望它会对你有所帮助
总结以上是内存溢出为你收集整理的折叠或展开时,Android expandablelistview组/父级背景图像会发生变化全部内容,希望文章能够帮你解决折叠或展开时,Android expandablelistview组/父级背景图像会发生变化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)