您好,登錄后才能下訂單哦!
這篇文章主要介紹了Android中如何實現TeaScreenPopupWindow多類型篩選彈框功能,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
引入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多類型篩選彈框功能”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。