@ -0,0 +1,59 @@
|
||||
package com.example.test1.GoodDatabase;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
public class Database extends SQLiteOpenHelper {
|
||||
|
||||
public Database(@Nullable Context context) {
|
||||
|
||||
super(context, "good", null, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
//创建用户表
|
||||
String sql = "create table good_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50),number carchar(50))";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
//插入数据
|
||||
public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city, String number ) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("username", username);
|
||||
contentValues.put("password", password);
|
||||
contentValues.put("sex", sex);
|
||||
contentValues.put("city", city);
|
||||
contentValues.put("number", number);
|
||||
sqLiteDatabase.insert("good_user", null, contentValues);
|
||||
sqLiteDatabase.close();
|
||||
}
|
||||
|
||||
//查询数据
|
||||
public static Bundle queryUserInfo(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
|
||||
String username = bundle.getString("username");
|
||||
Cursor cursor = sqLiteDatabase.rawQuery("select * from good_user where username=?", new String[]{username});
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
bundle.putString("sex", cursor.getString(3));
|
||||
bundle.putString("city", cursor.getString(4));
|
||||
bundle.putString("number", cursor.getString(5));
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
sqLiteDatabase.close();
|
||||
return bundle;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.example.test1.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.test1.R;
|
||||
import com.example.test1.entity.Condition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListViewAdapter extends BaseAdapter {
|
||||
private List<Condition> conditionList;
|
||||
private LayoutInflater layoutInflater;
|
||||
private int selectedPosition = -1;
|
||||
private int selectColor = Color.GRAY;
|
||||
|
||||
public ListViewAdapter(Context context, List<Condition> conditionList) {
|
||||
this.conditionList = conditionList;
|
||||
this.layoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return conditionList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return conditionList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.product_condition_item, null);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.imageView = convertView.findViewById(R.id.condition_icon);
|
||||
viewHolder.jiange = convertView.findViewById(R.id.image_jiange);
|
||||
viewHolder.textView = convertView.findViewById(R.id.condition_name);
|
||||
viewHolder.linearLayout = convertView.findViewById(R.id.item_bg);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
Condition condition = conditionList.get(position);
|
||||
if (condition != null) {
|
||||
viewHolder.imageView.setBackgroundResource(condition.getConditionIcon());
|
||||
viewHolder.textView.setText(condition.getConditionName());
|
||||
viewHolder.jiange.setBackgroundColor(Color.rgb(207, 207, 207));
|
||||
if (selectedPosition == position) {
|
||||
viewHolder.linearLayout.setBackgroundColor(selectColor);
|
||||
}
|
||||
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
ImageView imageView, jiange;
|
||||
TextView textView;
|
||||
LinearLayout linearLayout;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.example.test1.entity;
|
||||
|
||||
public class Condition {
|
||||
private Integer conditionIcon;
|
||||
private String conditionName;
|
||||
|
||||
public Integer getConditionIcon() {
|
||||
return conditionIcon;
|
||||
}
|
||||
|
||||
public void setConditionIcon(Integer conditionIcon) {
|
||||
this.conditionIcon = conditionIcon;
|
||||
}
|
||||
|
||||
public String getConditionName() {
|
||||
return conditionName;
|
||||
}
|
||||
|
||||
public void setConditionName(String conditionName) {
|
||||
this.conditionName = conditionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Condition{" +
|
||||
"conditionIcon=" + conditionIcon +
|
||||
", conditionName='" + conditionName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.example.test1.entity;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class Message {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Timestamp getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
|
||||
public void setSendTime(Timestamp sendTime) {
|
||||
this.sendTime = sendTime;
|
||||
}
|
||||
|
||||
public String getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public void setUsed(String used) {
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
private Integer id;
|
||||
private String content;
|
||||
private Timestamp sendTime;
|
||||
private String used;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrangeMessage{" +
|
||||
"id=" + id +
|
||||
", content='" + content + '\'' +
|
||||
", sendTime=" + sendTime +
|
||||
", used='" + used + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.example.test1.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class ProductPack {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Timestamp addTime;
|
||||
private Bitmap imgBitmap;
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
private String price;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrangeProductPack{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", addTime=" + addTime +
|
||||
", imgBitmap=" + imgBitmap +
|
||||
", price=" + price +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Timestamp getAddTime() {
|
||||
return addTime;
|
||||
}
|
||||
|
||||
public void setAddTime(Timestamp addTime) {
|
||||
this.addTime = addTime;
|
||||
}
|
||||
|
||||
public Bitmap getImgBitmap() {
|
||||
return imgBitmap;
|
||||
}
|
||||
|
||||
public void setImgBitmap(Bitmap imgBitmap) {
|
||||
this.imgBitmap = imgBitmap;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<corners android:radius="2dip"/>
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#FFFFFF"
|
||||
/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<bitmap android:src="@drawable/back"
|
||||
android:gravity="end"/>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="#F0A732" android:state_selected="true" />
|
||||
<item android:color="#CFCFCF" />
|
||||
</selector>
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,15 @@
|
||||
<?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">
|
||||
|
||||
<include layout="@layout/content_shoppingcart_title" />
|
||||
<!--有商品时的布局-->
|
||||
<GridView
|
||||
android:id="@+id/cart_productList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:numColumns="1" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,45 @@
|
||||
<?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:background="#F2F2F2"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/content_shoppingcart_title" />
|
||||
<!--无商品时的布局-->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="160dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/cart" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="购物车是空的~"
|
||||
android:textColor="#B5B5B5"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/random_search"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="25dp"
|
||||
android:background="@drawable/button_login"
|
||||
android:text="去逛逛"
|
||||
android:textColor="#fff"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,32 @@
|
||||
<?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:background="#fff"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/category_product_image"
|
||||
android:layout_width="120dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_product_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="#050505"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_product_price"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#050505"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
@ -1,11 +1,29 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
<include layout="@layout/content_product_title" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/product_select_condition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="product" />
|
||||
android:paddingHorizontal="1dp">
|
||||
<!-- android:minHeight="48dp">-->
|
||||
</Spinner>
|
||||
|
||||
<GridView
|
||||
android:id="@+id/product_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="#E8E8E8"
|
||||
android:horizontalSpacing="10dp"
|
||||
android:numColumns="2"
|
||||
android:verticalSpacing="10dp" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,33 @@
|
||||
<?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="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<!--标题-->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="#B9B9FF"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/category_return"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/back" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="商品"
|
||||
android:layout_marginRight="40dp"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,32 @@
|
||||
<?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="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<!--标题-->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="#B9B9FF"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/shopcart_return"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/back" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="购物车"
|
||||
android:layout_marginRight="40dp"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/item_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="#fff"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/condition_icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/condition_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="销量"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_jiange"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:background="#CFCFCF" />
|
||||
|
||||
</LinearLayout>
|