//登陆
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bwie.test.monidierzhou.MainActivity"> <TextView android:text="登录" android:textSize="18sp" android:gravity="center" android:layout_width="match_parent" android:layout_height="50dp" /> <TextView android:background="#f1ebeb" android:layout_width="match_parent" android:layout_height="5dp" /> <EditText android:id="@+id/login_umobile" android:hint="请输入手机号" android:layout_width="320dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="50dp" android:layout_marginBottom="30dp"/> <EditText android:id="@+id/login_upwd" android:hint="请输入密码" android:layout_width="320dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="30dp"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="30dp"> <Button android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:text="登录" android:onClick="login"/> <Button android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:text="注册" android:onClick="regist"/> </LinearLayout> </LinearLayout>//注册
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="60dp"> <TextView android:id="@+id/fan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="<" android:textSize="35dp"/> <TextView android:layout_width="match_parent" android:layout_height="60dp" android:text="注册" android:textSize="20dp" android:gravity="center"/> </RelativeLayout> <TextView android:layout_width="match_parent" android:layout_height="5dp" android:background="#f1ebeb"/> <EditText android:id="@+id/reg_umobile" android:hint="请输入手机号" android:layout_width="320dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="50dp" android:layout_marginBottom="30dp"/> <EditText android:id="@+id/reg_upwd" android:hint="请输入密码" android:layout_width="320dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="30dp"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="立即注册" android:textSize="25dp" android:textColor="#89f" android:onClick="goRegist" android:layout_gravity="center"/> </LinearLayout>
//搜索页面
<?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" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="60dp" android:padding="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索商品" android:textSize="35dp" android:layout_centerInParent="true"/> <CheckBox android:button="@null" android:layout_width="30dp" android:layout_height="30dp" android:id="@+id/ck" android:background="@drawable/myselect" android:layout_alignParentRight="true"/> </RelativeLayout> <TextView android:layout_width="match_parent" android:layout_height="3dp" android:background="#f1ebeb"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dp"> <EditText android:id="@+id/shu" android:layout_width="220dp" android:layout_height="wrap_content" android:hint="请输入关键字" android:layout_marginLeft="50dp"/> <Button android:onClick="search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索" android:layout_alignRight="@+id/shu"/> </LinearLayout> <TextView android:background="#f1ebeb" android:layout_width="match_parent" android:layout_height="3dp" /> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="wrap_content" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> </LinearLayout>
//grid.xml
<?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" android:layout_height="match_parent" android:padding="20dp"> <ImageView android:id="@+id/img" android:layout_width="180dp" android:layout_height="180dp" android:src="@mipmap/ic_launcher"/> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="ddddddddd"/> <TextView android:id="@+id/price" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="aaaaa"/> </LinearLayout> </LinearLayout>
//list.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="15dp"> <ImageView android:id="@+id/img" android:layout_width="100dp" android:layout_height="100dp" android:src="@mipmap/ic_launcher"/> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="ddddddddd"/> <TextView android:id="@+id/price" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="aaaaa"/> </LinearLayout> </LinearLayout>
添加的权限
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okio:okio:1.11.0' compile 'com.orhanobut:logger:2.1.1' compile 'com.github.bumptech.glide:glide:3.7.0' testCompile 'junit:junit:4.12' compile 'com.google.code.gson:gson:2.8.2' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'