布局代码:
<?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()]);