Browse Source

1.修改AddressItemView。

石慧云 4 years ago
parent
commit
d5ee7a5355

+ 2 - 2
app/src/main/java/com/quansu/heifengwuliu/fragment/OwnerSingleFragment.kt

@@ -55,8 +55,8 @@ class OwnerSingleFragment : MBFragment<BViewModel<BRepository>, FragmentOwnersin
     private fun initData() {
 
         //卸货信息
-         binding.viewEnter.tvCity.setHint("请选择卸货地址")
-        binding.viewEnter.llChoseMap.setOnClickListener {
+        binding.viewEnter.tvCity.hint = "请选择卸货地址"
+         binding.viewEnter.llChoseMap.setOnClickListener {
             //地图选点
             CCRetrofit.instance()
                     .with(context)

+ 14 - 26
app/src/main/java/com/quansu/heifengwuliu/widget/AddressItemView.java

@@ -2,12 +2,15 @@ package com.quansu.heifengwuliu.widget;
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.LayoutInflater;
 import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import com.qmuiteam.qmui.widget.QMUIRadiusImageView;
+import androidx.databinding.DataBindingUtil;
+
 import com.quansu.heifengwuliu.R;
+import com.quansu.heifengwuliu.databinding.WidgetAddressitemBinding;
 import com.ysnows.base.view.BView;
 import com.ysnows.base.view.BaseView;
 
@@ -17,17 +20,9 @@ import com.ysnows.base.view.BaseView;
  */
 public class AddressItemView extends BaseLinearLayout {
     private BView view;
-    private QMUIRadiusImageView img;
-    private TextView tvCity;
-    private LinearLayout llChoseAddress;
-    private EditText etDetailedAddress;
-    private LinearLayout llChoseMap;
-    private TextView tvChoseTime;
-    private EditText etName;
-    private EditText etPhone;
-
 
 
+    private WidgetAddressitemBinding binding;
 
 
 
@@ -49,15 +44,8 @@ public class AddressItemView extends BaseLinearLayout {
         if (context instanceof BaseView) {
             this.view = (BView) context;
         }
-        inflate(context, R.layout.widget_addressitem, this);
-        img = findViewById(R.id.img);
-        tvCity = findViewById(R.id.tv_city);
-        llChoseAddress = findViewById(R.id.ll_chose_address);
-        etDetailedAddress = findViewById(R.id.et_detailed_address);
-        llChoseMap = findViewById(R.id.ll_chose_map);
-        tvChoseTime = findViewById(R.id.tv_chose_time);
-        etName = findViewById(R.id.et_name);
-        etPhone = findViewById(R.id.et_phone);
+        binding= DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.widget_addressitem, this,true);
+
     }
 
 
@@ -67,26 +55,26 @@ public class AddressItemView extends BaseLinearLayout {
 
 
     public TextView getTvCity(){
-        return tvCity;
+        return binding.tvCity;
     }
     public TextView getTvChoseTime(){
-        return tvChoseTime;
+        return binding.tvChoseTime;
     }
     public LinearLayout getLlChoseAddress(){
-        return llChoseAddress;
+        return binding.llChoseAddress;
     }
     public LinearLayout getLlChoseMap(){
-        return llChoseMap;
+        return binding.llChoseMap;
     }
     public EditText getEtName(){
-        return etName;
+        return binding.etName;
     }
 
     public EditText getEtPhone(){
-        return etPhone;
+        return binding.etPhone;
     }
     public EditText getEtDetailedAddress(){
-        return etDetailedAddress;
+        return binding.etDetailedAddress;
     }
 
 

+ 178 - 167
app/src/main/res/layout/widget_addressitem.xml

@@ -1,202 +1,213 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_height="wrap_content">
-
-    <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="@dimen/dp_12"
-        android:layout_marginTop="@dimen/dp_10"
-        android:layout_marginEnd="@dimen/dp_12"
-        android:orientation="vertical"
-        android:paddingStart="@dimen/dp_10"
-        android:paddingTop="@dimen/dp_10"
-        android:paddingEnd="@dimen/dp_12"
-        android:paddingBottom="@dimen/dp_10"
-        app:qmui_borderColor="#BFBFBF"
-        app:qmui_borderWidth="@dimen/dp_1"
-        app:qmui_radius="@dimen/dp_2">
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center_vertical"
-            android:orientation="horizontal">
+<layout xmlns:android="http://schemas.android.com/apk/res/android" >
 
+    <data >
 
-            <com.qmuiteam.qmui.widget.QMUIRadiusImageView
-                android:id="@+id/img"
-                android:layout_width="25dp"
-                android:layout_height="25dp"
-                android:src="@drawable/ic_math"
-                app:qmui_is_circle="true" />
-
-
-            <TextView
-                android:id="@+id/tv_city"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="@dimen/dp_10"
-                android:layout_weight="1"
-                android:textColor="#101010"
-                android:textSize="@dimen/sp_16"
-                android:hint="请选择省市区"
-               ></TextView>
-
-            <LinearLayout
-                android:id="@+id/ll_chose_address"
-                android:layout_width="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_height="wrap_content">
-
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="@dimen/dp_10"
-                android:layout_marginEnd="@dimen/dp_10"
-                android:text="地址薄"
-                android:textColor="#5E5C5C"
-                android:textSize="@dimen/sp_15"></TextView>
-
-            <ImageView
-                style="@style/mine_arrow_right"
-                android:src="@drawable/mine_right" />
-            </LinearLayout>
-        </LinearLayout>
+    </data >
 
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+        android:orientation="vertical">
 
-        <LinearLayout
+        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/dp_12"
             android:layout_marginTop="@dimen/dp_10"
-            android:gravity="center_vertical"
-            android:orientation="horizontal">
-
+            android:layout_marginEnd="@dimen/dp_12"
+            android:orientation="vertical"
+            android:paddingStart="@dimen/dp_10"
+            android:paddingTop="@dimen/dp_10"
+            android:paddingEnd="@dimen/dp_12"
+            android:paddingBottom="@dimen/dp_10"
+            app:qmui_borderColor="#BFBFBF"
+            app:qmui_borderWidth="@dimen/dp_1"
+            app:qmui_radius="@dimen/dp_2">
 
-            <EditText
-                android:id="@+id/et_detailed_address"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="35dp"
-                android:layout_weight="1"
-                android:background="@null"
-                android:hint="请输入详细地址"
-                android:textColor="#101010"
-                android:textColorHint="#BBBBBB"
-                android:textSize="@dimen/sp_15"></EditText>
-
-        <LinearLayout
-            android:id="@+id/ll_chose_map"
-            android:layout_width="wrap_content"
-            android:gravity="center_vertical"
-            android:layout_height="wrap_content">
-            <TextView
-                android:layout_width="wrap_content"
+            <LinearLayout
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_marginStart="@dimen/dp_10"
-                android:layout_marginEnd="@dimen/dp_10"
-                android:text="地图选点"
-                android:textColor="#5E5C5C"
-                android:textSize="@dimen/sp_15"></TextView>
+                android:gravity="center_vertical"
+                android:orientation="horizontal">
 
-            <ImageView
-                android:layout_width="20dp"
-                android:layout_height="20dp"
-                android:src="@drawable/map_address" />
 
-        </LinearLayout>
+                <com.qmuiteam.qmui.widget.QMUIRadiusImageView
+                    android:id="@+id/img"
+                    android:layout_width="25dp"
+                    android:layout_height="25dp"
+                    android:src="@drawable/ic_math"
+                    app:qmui_is_circle="true" />
 
-        </LinearLayout>
 
+                <TextView
+                    android:id="@+id/tv_city"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/dp_10"
+                    android:layout_weight="1"
+                    android:hint="请选择省市区"
+                    android:textColor="#101010"
+                    android:textSize="@dimen/sp_16"></TextView>
+
+                <LinearLayout
+                    android:id="@+id/ll_chose_address"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_vertical">
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginStart="@dimen/dp_10"
+                        android:layout_marginEnd="@dimen/dp_10"
+                        android:text="地址薄"
+                        android:textColor="#5E5C5C"
+                        android:textSize="@dimen/sp_15"></TextView>
+
+                    <ImageView
+                        style="@style/mine_arrow_right"
+                        android:src="@drawable/mine_right" />
+                </LinearLayout>
+            </LinearLayout>
 
-        <TextView
-            android:id="@+id/tv_chose_time"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginStart="35dp"
-            android:layout_marginTop="@dimen/dp_10"
-            android:hint="点击选择装货时间"
-            android:textColor="#5E5C5C"
-            android:textSize="@dimen/sp_15"></TextView>
 
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/dp_10"
-            android:layout_marginBottom="@dimen/dp_10"
-            android:gravity="center_vertical"
-            android:orientation="horizontal">
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal">
 
 
-            <ImageView
-                android:layout_width="20dp"
-                android:layout_height="20dp"
-                android:layout_marginStart="35dp"
-                android:layout_marginEnd="@dimen/dp_10"
-                android:src="@drawable/ic_math" />
-
-            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
-                android:layout_width="0dp"
-                android:layout_height="35dp"
-                android:layout_weight="1"
-                android:padding="@dimen/dp_2"
-                app:qmui_borderColor="#BFBFBF"
-                app:qmui_borderWidth="@dimen/dp_1"
-                app:qmui_radius="@dimen/dp_2">
-
                 <EditText
-                    android:id="@+id/et_name"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
+                    android:id="@+id/et_detailed_address"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="35dp"
+                    android:layout_weight="1"
                     android:background="@null"
-                    android:hint="姓名"
+                    android:hint="请输入详细地址"
                     android:textColor="#101010"
                     android:textColorHint="#BBBBBB"
-                    android:textSize="@dimen/sp_15">
+                    android:textSize="@dimen/sp_15"></EditText>
+
+                <LinearLayout
+                    android:id="@+id/ll_chose_map"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_vertical">
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginStart="@dimen/dp_10"
+                        android:layout_marginEnd="@dimen/dp_10"
+                        android:text="地图选点"
+                        android:textColor="#5E5C5C"
+                        android:textSize="@dimen/sp_15"></TextView>
+
+                    <ImageView
+                        android:layout_width="20dp"
+                        android:layout_height="20dp"
+                        android:src="@drawable/map_address" />
+
+                </LinearLayout>
+
+            </LinearLayout>
 
-                </EditText>
 
-            </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
+            <TextView
+                android:id="@+id/tv_chose_time"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="35dp"
+                android:layout_marginTop="@dimen/dp_10"
+                android:hint="点击选择装货时间"
+                android:textColor="#5E5C5C"
+                android:textSize="@dimen/sp_15"></TextView>
 
-            <ImageView
-                android:layout_width="20dp"
-                android:layout_height="20dp"
-                android:layout_marginStart="@dimen/dp_15"
-                android:layout_marginEnd="@dimen/dp_10"
-                android:src="@drawable/ic_math" />
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginBottom="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal">
+
+
+                <ImageView
+                    android:layout_width="20dp"
+                    android:layout_height="20dp"
+                    android:layout_marginStart="35dp"
+                    android:layout_marginEnd="@dimen/dp_10"
+                    android:src="@drawable/ic_math" />
+
+                <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+                    android:layout_width="0dp"
+                    android:layout_height="35dp"
+                    android:layout_weight="1"
+                    android:padding="@dimen/dp_2"
+                    app:qmui_borderColor="#BFBFBF"
+                    app:qmui_borderWidth="@dimen/dp_1"
+                    app:qmui_radius="@dimen/dp_2">
+
+                    <EditText
+                        android:id="@+id/et_name"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:background="@null"
+                        android:hint="姓名"
+                        android:textColor="#101010"
+                        android:textColorHint="#BBBBBB"
+                        android:textSize="@dimen/sp_15">
+
+                    </EditText>
+
+                </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
+
+                <ImageView
+                    android:layout_width="20dp"
+                    android:layout_height="20dp"
+                    android:layout_marginStart="@dimen/dp_15"
+                    android:layout_marginEnd="@dimen/dp_10"
+                    android:src="@drawable/ic_math" />
+
+                <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+                    android:layout_width="0dp"
+                    android:layout_height="35dp"
+                    android:layout_weight="1"
+                    android:padding="@dimen/dp_2"
+                    app:qmui_borderColor="#BFBFBF"
+                    app:qmui_borderWidth="@dimen/dp_1"
+                    app:qmui_radius="@dimen/dp_2">
+
+                    <EditText
+                        android:id="@+id/et_phone"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:background="@null"
+                        android:hint="电话"
+                        android:textColor="#101010"
+                        android:textColorHint="#BBBBBB"
+                        android:textSize="@dimen/sp_15">
+
+                    </EditText>
+
+                </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
 
-            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
-                android:layout_width="0dp"
-                android:layout_height="35dp"
-                android:layout_weight="1"
-                android:padding="@dimen/dp_2"
-                app:qmui_borderColor="#BFBFBF"
-                app:qmui_borderWidth="@dimen/dp_1"
-                app:qmui_radius="@dimen/dp_2">
 
-                <EditText
-                    android:id="@+id/et_phone"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:background="@null"
-                    android:hint="电话"
-                    android:textColor="#101010"
-                    android:textColorHint="#BBBBBB"
-                    android:textSize="@dimen/sp_15">
+            </LinearLayout>
+
 
-                </EditText>
+        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
 
-            </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
 
+    </LinearLayout>
 
-        </LinearLayout>
 
+</layout >
 
-    </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
 
 
-</LinearLayout>