Android中 TeaScreenPopupWindow多類型篩選彈框功能的實(shí)例代碼
Github地址
YangsBryant/TeaScreenPopupWindow
(Github排版比較好,建議進(jìn)入這里查看詳情,如果覺得好,點(diǎn)個(gè)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);
//默認(rèn)單選,因?yàn)楣灿玫囊粋€(gè)bean,這里調(diào)用reset重置下數(shù)據(jù)
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);
//設(shè)置多選,因?yàn)楣灿玫囊粋€(gè)bean,這里調(diào)用reset重置下數(shù)據(jù)
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 = {"花花公子", "語克","優(yōu)衣庫", "美特斯邦威", "森馬", "翰代維", "PUMA"};
String[] type = {"男裝", "T恤", "運(yùn)動服", "女裝", "童裝", "緊身衣"};
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) | 設(shè)置頂部分割線是否顯示,以及顏色。默認(rèn)true,#f3f3f3 |
| setBottomView(Boolean bl, int color) | 設(shè)置底部分割線是否顯示,以及顏色。默認(rèn)true,#f3f3f3 |
| setConfirm(String text, int size, int textColor, int color) | 設(shè)置確定按鈕的文字,字體大小,字體顏色,背景顏色。默認(rèn)“確定”,14,#ffffff,#0aa666 |
| setReset(String text, int size, int textColor, int color) | 設(shè)置重置按鈕的文字,字體大小,字體顏色,背景顏色。默認(rèn)“重置”,#000000,#ffffff |
| setAlpha(int mAlpha) | 設(shè)置陰影層的透明度 默認(rèn)是0.5f |
| setTitleColor(int color) | 設(shè)置title的字體顏色,默認(rèn)#000000 |
| setTitleSize(int size) | 設(shè)置title的字體大小,默認(rèn)14 |
| setRadius(int radius) | 設(shè)置item圓角大小,默認(rèn)12 |
| setStrokeWidth(int width) | 設(shè)置item邊框粗細(xì),默認(rèn)2 |
| setStrokeColor(int color) | 設(shè)置item邊框顏色,默認(rèn)#0aa666 |
| setBoxWidth(int width) | 設(shè)置item寬度,默認(rèn)是200dp |
| setBoxHeight(int height) | 設(shè)置item高度,默認(rèn)是WRAP_CONTENT |
| setChecked(String color) | 設(shè)置item選中時(shí)的顏色,默認(rèn)#0aa666 |
| setEnabled(String color) | 設(shè)置item未選中時(shí)的顏色,默認(rèn)#000000 |
| setBoxSize(int size) | 設(shè)置item字體大小,默認(rèn)13 |
| setSingle(boolean bl) | 設(shè)置是否開啟單選,默認(rèn)單選 |
| reset() | 顯示控件時(shí)數(shù)據(jù)重置 |
| build() | 參數(shù)設(shè)置完畢,一定要build一下 |
總結(jié)
以上所述是小編給大家介紹的Android中 TeaScreenPopupWindow多類型篩選彈框功能的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- Android高德地圖marker自定義彈框窗口
- Android自定義彈框樣式
- Android啟動頁用戶相關(guān)政策彈框的實(shí)現(xiàn)代碼
- Android 實(shí)現(xiàn)抖音頭像底部彈框效果的實(shí)例代碼
- android自定義Dialog彈框和背景陰影顯示效果
- Android 提交或者上傳數(shù)據(jù)時(shí)的dialog彈框動畫效果
- Android簡單實(shí)現(xiàn)自定義彈框(PopupWindow)
- 淺析Android中常見三種彈框在項(xiàng)目中的應(yīng)用
- Android填坑系列:在小米系列等機(jī)型上放開定位權(quán)限后的定位請求彈框示例
- Android自定義彈框Dialog效果
相關(guān)文章
RecyclerView仿應(yīng)用列表實(shí)現(xiàn)網(wǎng)格布局
這篇文章主要為大家詳細(xì)介紹了RecyclerView仿應(yīng)用列表實(shí)現(xiàn)網(wǎng)格布局,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09
Android HttpURLConnection.getResponseCode()錯(cuò)誤解決方法
在使用HttpURLConnection.getResponseCode()的時(shí)候直接報(bào)錯(cuò)是IOException錯(cuò)誤,一直想不明白,同一個(gè)程序我調(diào)用了兩次,結(jié)果有一個(gè)鏈接一直O(jiān)K,另一個(gè)卻一直報(bào)這個(gè)錯(cuò)誤2013-06-06
Android中EditText的drawableRight屬性設(shè)置點(diǎn)擊事件
這篇文章主要介紹了Android中EditText的drawableRight屬性的圖片設(shè)置點(diǎn)擊事件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-10-10
Android USB轉(zhuǎn)串口通信開發(fā)實(shí)例詳解
這篇文章主要介紹了 Android USB轉(zhuǎn)串口通信開發(fā)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-04-04
Android嵌套滾動與協(xié)調(diào)滾動的實(shí)現(xiàn)方式匯總
如何實(shí)現(xiàn)這種協(xié)調(diào)滾動的布局呢,我們使用CoordinatorLayout+AppBarLayout或者CoordinatorLayout+Behavior實(shí)現(xiàn),另一種方案是MotionLayout,我們看看都是怎么實(shí)現(xiàn)的吧2022-06-06

