最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 中TeaPickerView數(shù)據(jù)級(jí)聯(lián)選擇器功能的實(shí)例代碼

 更新時(shí)間:2019年06月05日 15:05:29   作者:YangBryant  
這篇文章主要介紹了Android TeaPickerView數(shù)據(jù)級(jí)聯(lián)選擇器 ,需要的朋友可以參考下

Github地址

YangsBryant/TeaPickerView

(Github排版比較好,建議進(jìn)入這里查看詳情,如果覺(jué)得好,點(diǎn)個(gè)star吧!)

引入module

allprojects {
  repositories {
    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
  }
} 
implementation 'com.github.YangsBryant:TeaPickerView:1.0.2'

主要代碼

public class MainActivity extends AppCompatActivity {
  @BindView(R.id.mButton)
  Button button;
  List<String> mProvinceDatas=new ArrayList<>();
  Map<String, List<String>> mSecondDatas= new HashMap<>();
  Map<String, List<String>> mThirdDatas= new HashMap<>();
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind( this );
    intiPickerView();
  }
  private void intiPickerView(){
    //一級(jí)列表
    ProvinceBean provinceBean = new ProvinceBean();
    mProvinceDatas.addAll(provinceBean.getRepData().getProvince());
    //二級(jí)列表
    SecondBean secondBean = new SecondBean();
    mSecondDatas.putAll(secondBean.getRepData().getSecond());
    //三級(jí)列表
    ThirdBean thirdBean = new ThirdBean();
    mThirdDatas.putAll(thirdBean.getRepData().getThird());
    Log.i("json", JsonArrayUtil.toJson(mProvinceDatas));
    Log.i("json",JsonArrayUtil.toJson(mSecondDatas));
    Log.i("json",JsonArrayUtil.toJson(mThirdDatas));
    //設(shè)置數(shù)據(jù)有多少層級(jí)
    PickerData data=new PickerData();
    data.setFirstDatas(mProvinceDatas);//json: ["廣東","江西"]
    data.setSecondDatas(mSecondDatas);//json: {"江西":["南昌","贛州"],"廣東":["廣州","深圳","佛山","東莞"]}
    data.setThirdDatas(mThirdDatas);//json: {"廣州":["天河區(qū)","白云區(qū)","番禹區(qū)","花都區(qū)"],"贛州":["章貢區(qū)","黃金開(kāi)發(fā)區(qū)"],"東莞":["東城","南城"],"深圳":["南山區(qū)","寶安區(qū)","龍華區(qū)"],"佛山":["禪城區(qū)","順德區(qū)"],"南昌":["東湖區(qū)","青云譜區(qū)","青山湖區(qū)"]}
    data.setInitSelectText("請(qǐng)選擇");
    TeaPickerView teaPickerView =new TeaPickerView(this,data);
    teaPickerView.setScreenH(3)
        .setDiscolourHook(true)
        .setRadius(25)
        .setContentLine(true)
        .setRadius(25)
        .build();
    button.setOnClickListener(v -> {
      //顯示選擇器
      teaPickerView.show(button);
    });
    //選擇器點(diǎn)擊事件
    teaPickerView.setOnPickerClickListener(pickerData -> {
      Toast.makeText(MainActivity.this,pickerData.getFirstText()+","+pickerData.getSecondText()+","+pickerData.getThirdText(),Toast.LENGTH_SHORT).show();
      teaPickerView.dismiss();//關(guān)閉選擇器
    });
  }
}

TeaPickerView屬性大全

方法名

屬性

setHeights(int mHeight)

顯示具體的高度(dp),設(shè)置0是自適應(yīng)(高度沒(méi)有默認(rèn)值,需要主動(dòng)設(shè)置)
setScreenH(int num) 顯示的高度占屏幕的百分比
setBackground(int color) 設(shè)置整體的背景顏色 默認(rèn)是#ffffff
setRadius(int mRadius) 設(shè)置圓角,默認(rèn)0
setContentBackground(int color) 內(nèi)容欄的背景顏色 默認(rèn)是#ffffff
setContentHeight(int mHeight) 內(nèi)容欄的高度(dp) 默認(rèn)是50dp
setContentText(int size,int color) 內(nèi)容欄字體的大小和顏色, 默認(rèn)是16sp,#0aa666,用此方法會(huì)固定顏色
setContentText(ColorStateList drawable) 自定義內(nèi)容欄字體顏色變換器 在res目錄下創(chuàng)建color文件夾用selector 默認(rèn)顏色#555 選中顏色#0aa666
setContentLine(boolean bl) 內(nèi)容欄選中是否有下劃線 默認(rèn)不開(kāi)啟
setContentLineColor(Drawable drawable) 自定義內(nèi)容欄下劃線用layer-list 默認(rèn)是下邊框描邊 顏色#0fbc72 高度1dp
setLine(int mHeight,int color) 分割線的高度和顏色 默認(rèn)是0.5dp #e5e5e5
setitemHeight(int mHeight) 設(shè)置list的item的高度(dp) 默認(rèn)是40dp
setListText(int size,int color) 設(shè)置list的字體大小和顏色 默認(rèn)是15 #555
setScrollBal(boolean bl) 設(shè)置list是否顯示滾動(dòng)條,默認(rèn)false
setAlpha(float mFloat) 設(shè)置陰影層的透明度 默認(rèn)是0.5f
setDiscolour(boolean bl) 設(shè)置選中項(xiàng)是否加色,默認(rèn)true
setDiscolourColor(int color) 設(shè)置選中項(xiàng)加色的顏色值,默認(rèn)#0aa666
setDiscolourHook(boolean bl) 設(shè)置選中項(xiàng)是否有√圖標(biāo),默認(rèn)false
setCustomHook(Drawable drawable) 自定義√圖標(biāo)
build() 參數(shù)設(shè)置完畢,一定要build

設(shè)置數(shù)據(jù)

方法名 屬性                  
setInitSelectText(String firstText) 初始文字
setFirstDatas(List mFirstDatas) 設(shè)置一級(jí)數(shù)據(jù)
setSecondDatas(Map<String, List> mSecondDatas) 設(shè)置二級(jí)數(shù)據(jù)
setThirdDatas(Map<String, List> mThirdDatas) 設(shè)置三級(jí)數(shù)據(jù)
setFourthDatas(Map<String, List> mFourthDatas)

給出參考bean地址

一級(jí)ProvinceBean

二級(jí)SecondBean

三級(jí)ThirdBean

默認(rèn)內(nèi)容欄字體顏色變換器

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_selected="true" android:color="@color/picker_select_text_color"/>
  <item android:state_pressed="true" android:color="@color/picker_select_text_color"/>
  <item android:state_checked="true" android:color="@color/picker_select_text_color"/>
  <item android:state_focused="true" android:color="@color/picker_select_text_color"/>
  <item android:color="@color/picker_text_color"/>
</selector> 

默認(rèn)內(nèi)容欄下劃線

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  <!-- 邊框顏色值 -->
  <item>
    <shape>
      <solid android:color="@color/station_average" />
    </shape>
  </item>
  <item android:bottom="1dp"> <!--設(shè)置只有底部有邊框-->
    <shape>
      <solid android:color="#ffffff" />
    </shape>
  </item>
</layer-list> 

總結(jié)

 以上所述是小編給大家介紹的Android 中TeaPickerView數(shù)據(jù)級(jí)聯(lián)選擇器功能的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

都安| 洪江市| 日喀则市| 志丹县| 洪洞县| 牡丹江市| 扎囊县| 沽源县| 富蕴县| 泰宁县| 卢湾区| 定州市| 通辽市| 深泽县| 巴里| 中西区| 鄂州市| 华宁县| 石景山区| 宁德市| 武隆县| 云浮市| 桂东县| 江华| 布尔津县| 平罗县| 即墨市| 咸丰县| 东乌珠穆沁旗| 定边县| 阿瓦提县| 昌图县| 南雄市| 循化| 渭源县| 太湖县| 安阳县| 水城县| 鄂伦春自治旗| 临邑县| 伊川县|