Github地址 YangsBryant/TeaScreenPopupWindow (Github排版比较好,建议进入这里查看详情,如果觉得好,点个star吧!) 引入module allprojects { repositories { google() jcenter() maven { url 'https://www.jitpack.io' }
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属性大全
总结
以上所述是小编给大家介绍的Android中 TeaScreenPopupWindow多类型筛选弹框功能的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对自由互联网站的支持!