自定义TabLayout布局的基本方法

布局代码:
<?xml version="1.0" encoding="utf-8"?>
<com.zhy.autolayout.AutoLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical"
    tools:context="com.ryx.ryxcredit.ryd.BorrowRecordsActivity">

    <include layout="@layout/c_widget_title" />

    <com.zhy.autolayout.AutoLinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <com.zhy.autolayout.AutoLinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:orientation="vertical">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#ffffffff"
                app:elevation="0dp">

                <android.support.design.widget.TabLayout
                    android:id="@+id/c_tl_borrow_records"
                    android:layout_width="match_parent"
                    android:layout_height="55dp"
                    app:tabSelectedTextColor="@color/xd_blue"
                    app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
                    app:tabTextColor="@color/threeblack">

                </android.support.design.widget.TabLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1px"
                    android:background="@color/fourblack" />
            </android.support.design.widget.AppBarLayout>

        </com.zhy.autolayout.AutoLinearLayout>

        <com.rey.material.widget.Spinner
            android:id="@+id/sp_product"
            style="@style/Material.Widget.Spinner"
            android:layout_width="0dp"
            android:layout_height="55dp"
            android:layout_weight="1"
            app:rd_style="@style/Material.Drawable.Ripple.Wave" />
    </com.zhy.autolayout.AutoLinearLayout>

    <FrameLayout
        android:id="@+id/c_fl_borrow_records"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>
</com.zhy.autolayout.AutoLinearLayout>


View tab1View = LayoutInflater.from(this).inflate(R.layout.c_borrowrecord_tabitem_new, null);
tv1 = (TextView) tab1View.findViewById(R.id.text1);
iv1 = (ImageView) tab1View.findViewById(R.id.iv);
tv1.setText("待还款");
View tab2View = LayoutInflater.from(this).inflate(R.layout.c_borrowrecord_tabitem_new, null);
tv2 = (TextView) tab2View.findViewById(R.id.text1);
iv2 = (ImageView) tab2View.findViewById(R.id.iv);
tv2.setText("已结清");

tabA = tabLayout.newTab().setCustomView(tab1View);
tabLayout.addTab(tabA);
tabB = tabLayout.newTab().setCustomView(tab2View);
tabLayout.addTab(tabB);
initSpinner();

private void initSpinner() {
    spn_label = (Spinner) findViewById(R.id.sp_product);
    String[] items = new String[]{"全部", "瑞易贷", "瑞卡贷"};
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.row_spn, items);
    adapter.setDropDownViewResource(R.layout.row_spn_dropdown);
    spn_label.setAdapter(adapter);
    spn_label.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
        @Override
        public void onItemSelected(Spinner parent, View view, int position, long id) {
               requestBorrowRecord(mstatus,mflag,productStrs[position]);
        }
    });
}
//spinner 产品列表,全部,瑞卡贷,现金贷
private String[] productStrs = {"", RyxcreditConfig.rkd_procudtid,RyxcreditConfig.xjd_procudtId};

请求的时候需要传递的标签:
request.setProduct_id(productStrs[spn_label.getSelectedItemPosition()]);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值