Android改变ExpandableListView的indicator图标实现方法
本文实例讲述了Android改变ExpandableListView的indicator图标实现方法。分享给大家供大家参考,具体如下:
1)定义xml文件先,命名为expand_list_indicator.xml
<?xmlversion="1.0"encoding="UTF-8"?> <selectorxmlns:android="http://schemas.android.com/apk/res/android"> <itemandroid:state_expanded="true"android:drawable="@drawable/indicator_open"/> <itemandroid:state_expanded="false"android:drawable="@drawable/indicator_close"/> </selector>
2)在得到ExpandableListView实例id后调用xml文件
ExpandableListViewmExpandList=(ExpandableListView)findViewById(R.id.expandlist); mExpandList.setGroupIndicator(this.getResources().getDrawable(R.drawable.expand_list_indicator));
注意事项:因为indicator背景图片会自动拉伸,如果不想图片被拉伸的话,那么就对indicator_open,indicator_close图片做特殊处理,做成.9.png格式就可以了。
更多关于Android相关内容感兴趣的读者可查看本站专题:《Android调试技巧与常见问题解决方法汇总》、《Android开发入门与进阶教程》、《Android多媒体操作技巧汇总(音频,视频,录音等)》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》
希望本文所述对大家Android程序设计有所帮助。