Android中 TeaScreenPopupWindow多类型筛选弹框功能的实例代码
程序员文章站
2023-08-15 22:42:05
github地址
yangsbryant/teascreenpopupwindow
(github排版比较好,建议进入这里查看详情,如果觉得好,点个star吧!)...
github地址
yangsbryant/teascreenpopupwindow
(github排版比较好,建议进入这里查看详情,如果觉得好,点个star吧!)
引入module
allprojects { repositories { google() jcenter() maven { url 'https://www.jitpack.io' } } } implementation 'com.github.yangsbryant:teascreenpopupwindow:1.0.2'
主要代码
public class mainactivity extends appcompatactivity { @bindview(r.id.button) button button; @bindview(r.id.button2) button button2; private screenpopwindow screenpopwindow; private list<filtratebean> dictlist = new arraylist<>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); butterknife.bind( this ); initparam(); initview(); } private void initview() { button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { screenpopwindow = new screenpopwindow(mainactivity.this, dictlist); //默认单选,因为共用的一个bean,这里调用reset重置下数据 screenpopwindow.reset().build(); screenpopwindow.showasdropdown(button); screenpopwindow.setonconfirmclicklistener(new screenpopwindow.onconfirmclicklistener() { @override public void onconfirmclick(list<string> list) { stringbuilder str = new stringbuilder(); for (int i=0;i<list.size();i++) { str.append(list.get(i)).append(" "); } toast.maketext(mainactivity.this, str.tostring(), toast.length_short).show(); } }); } }); button2.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { screenpopwindow = new screenpopwindow(mainactivity.this, dictlist); //设置多选,因为共用的一个bean,这里调用reset重置下数据 screenpopwindow.setsingle(false).reset().build(); screenpopwindow.showasdropdown(button2); screenpopwindow.setonconfirmclicklistener(new screenpopwindow.onconfirmclicklistener() { @override public void onconfirmclick(list<string> list) { stringbuilder str = new stringbuilder(); for (int i=0;i<list.size();i++) { str.append(list.get(i)).append(" "); } toast.maketext(mainactivity.this, str.tostring(), toast.length_short).show(); } }); } }); } private void initparam() { string[] brand = {"花花公子", "语克","优衣库", "美特斯邦威", "森马", "翰代维", "puma"}; string[] type = {"男装", "t恤", "运动服", "女装", "童装", "紧身衣"}; filtratebean fb1 = new filtratebean(); fb1.settypename("品牌"); list<filtratebean.children> childrenlist = new arraylist<>(); for (string abrand : brand) { filtratebean.children cd = new filtratebean.children(); cd.setvalue(abrand); childrenlist.add(cd); } fb1.setchildren(childrenlist); filtratebean fb2 = new filtratebean(); fb2.settypename("类型"); list<filtratebean.children> childrenlist2 = new arraylist<>(); for (string atype : type) { filtratebean.children cd = new filtratebean.children(); cd.setvalue(atype); childrenlist2.add(cd); } fb2.setchildren(childrenlist2); dictlist.add(fb1); dictlist.add(fb2); } }
teascreenpopupwindow属性大全
方法 | 属性 |
settopview(boolean bl, int color) | 设置顶部分割线是否显示,以及颜色。默认true,#f3f3f3 |
setbottomview(boolean bl, int color) | 设置底部分割线是否显示,以及颜色。默认true,#f3f3f3 |
setconfirm(string text, int size, int textcolor, int color) | 设置确定按钮的文字,字体大小,字体颜色,背景颜色。默认“确定”,14,#ffffff,#0aa666 |
setreset(string text, int size, int textcolor, int color) | 设置重置按钮的文字,字体大小,字体颜色,背景颜色。默认“重置”,#000000,#ffffff |
setalpha(int malpha) | 设置阴影层的透明度 默认是0.5f |
settitlecolor(int color) | 设置title的字体颜色,默认#000000 |
settitlesize(int size) | 设置title的字体大小,默认14 |
setradius(int radius) | 设置item圆角大小,默认12 |
setstrokewidth(int width) | 设置item边框粗细,默认2 |
setstrokecolor(int color) | 设置item边框颜色,默认#0aa666 |
setboxwidth(int width) | 设置item宽度,默认是200dp |
setboxheight(int height) | 设置item高度,默认是wrap_content |
setchecked(string color) | 设置item选中时的颜色,默认#0aa666 |
setenabled(string color) | 设置item未选中时的颜色,默认#000000 |
setboxsize(int size) | 设置item字体大小,默认13 |
setsingle(boolean bl) | 设置是否开启单选,默认单选 |
reset() | 显示控件时数据重置 |
build() | 参数设置完毕,一定要build一下 |
总结
以上所述是小编给大家介绍的android中 teascreenpopupwindow多类型筛选弹框功能的实例代码,希望对大家有所帮助