diff --git a/app/build.gradle b/app/build.gradle index 00a9f41..dc6b522 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,4 +39,6 @@ dependencies { implementation 'liji.library.dev:citypickerview:1.1.0' + + implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bc295fc..8313eaa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -28,7 +28,7 @@ - + \ No newline at end of file diff --git a/app/src/main/java/com/example/register/IndexActivity.java b/app/src/main/java/com/example/register/IndexActivity.java new file mode 100644 index 0000000..7d06d81 --- /dev/null +++ b/app/src/main/java/com/example/register/IndexActivity.java @@ -0,0 +1,122 @@ +package com.example.register; + +import android.app.Activity; +import android.app.FragmentTransaction; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; + +import com.example.register.fragment.IndexFragment; +import com.example.register.fragment.PearsonFragment; +import com.example.register.fragment.ProductFragment; +import com.example.register.fragment.ShoppingCartFragment; + +import com.example.register.R; + + +public class IndexActivity extends Activity implements View.OnClickListener { + private IndexFragment indexFragment; + private ProductFragment productFragment; + private ShoppingCartFragment shoppingCartFragment; + private PearsonFragment pearsonFragment; + private LinearLayout indexLine, productLine, shoppingCartLine, pearsonLine; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + init(); + initIndexFragment(); + } + + /** + * 组件初始化 + */ + private void init() { + indexLine = findViewById(R.id.content_index); + indexLine.setOnClickListener(this); + productLine = findViewById(R.id.content_product); + productLine.setOnClickListener(this); + shoppingCartLine = findViewById(R.id.content_cart); + shoppingCartLine.setOnClickListener(this); + pearsonLine = findViewById(R.id.content_pearson); + pearsonLine.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.content_index: + initIndexFragment(); + break; + case R.id.content_product: + initproductFragment(); + break; + case R.id.content_cart: + initshoppingCartFragment(); + break; + case R.id.content_pearson: + initpearsonFragment(); + break; + } + } + + /** + * 初始化首页Fragment + */ + private void initIndexFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (indexFragment == null) { + indexFragment = new IndexFragment(); + } + transaction.replace(R.id.main_content, indexFragment); + transaction.commit(); + } + + /** + * 初始化产品Fragment + */ + private void initproductFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (productFragment == null) { + productFragment = new ProductFragment(); + } + transaction.replace(R.id.main_content, productFragment); + transaction.commit(); + } + + /** + * 初始化购物车Fragment + */ + private void initshoppingCartFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (shoppingCartFragment == null) { + shoppingCartFragment = new ShoppingCartFragment(); + } + transaction.replace(R.id.main_content, shoppingCartFragment); + transaction.commit(); + } + + /** + * 初始化个人Fragment + */ + private void initpearsonFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (pearsonFragment == null) { + Intent intent = IndexActivity.this.getIntent(); + Bundle bundle = intent.getExtras(); + pearsonFragment = new PearsonFragment(); + pearsonFragment.setArguments(bundle); + } + transaction.replace(R.id.main_content, pearsonFragment); + transaction.commit(); + } + +} diff --git a/app/src/main/java/com/example/register/SetDetailFragment.java b/app/src/main/java/com/example/register/SetDetailFragment.java index 0d79577..c878085 100644 --- a/app/src/main/java/com/example/register/SetDetailFragment.java +++ b/app/src/main/java/com/example/register/SetDetailFragment.java @@ -18,7 +18,7 @@ import java.util.Objects; public class SetDetailFragment extends Fragment { private View view; private ImageView imageView; - private TextView nameText, priceText; + private TextView nameText, priceText ,storyText; @SuppressLint("SetTextI18n") @Nullable @@ -30,14 +30,15 @@ public class SetDetailFragment extends Fragment { } CategoryActivity categoryActivity = (CategoryActivity) getActivity(); Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> { - Log.i("sss", "onCreateView: " + product.getProductName()); - imageView.setBackgroundResource(product.getImageUrlId()); - nameText.setText(product.getProductName()); - priceText.setText(product.getProductPrice().toString()); - }); + Log.i("sss", "onCreateView: " + product.getProductName()); + imageView.setBackgroundResource(product.getImageUrlId()); + nameText.setText(product.getProductName()); + priceText.setText(product.getProductPrice().toString()); + }); return view; } + /** * 内容组件初始化 */ @@ -48,3 +49,4 @@ public class SetDetailFragment extends Fragment { } } + diff --git a/app/src/main/java/com/example/register/adapter/ProductAdapter.java b/app/src/main/java/com/example/register/adapter/ProductAdapter.java new file mode 100644 index 0000000..f52705e --- /dev/null +++ b/app/src/main/java/com/example/register/adapter/ProductAdapter.java @@ -0,0 +1,69 @@ +package com.example.register.adapter; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import com.example.register.entity.Product; +import com.example.register.R; + +import java.util.List; + +public class ProductAdapter extends BaseAdapter { + private List productList; + private LayoutInflater layoutInflater; + + public ProductAdapter(Context context, List productList) { + this.productList = productList; + this.layoutInflater = LayoutInflater.from(context); + } + + @Override + public int getCount() { + return productList.size(); + } + + @Override + public Object getItem(int position) { + return productList.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) { + Log.i("aa", "getView: "+"aa"); + convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null); + viewHolder = new ViewHolder(); + viewHolder.productImage = convertView.findViewById(R.id.category_product_image); + viewHolder.productName = convertView.findViewById(R.id.category_product_name); + viewHolder.productPrice = convertView.findViewById(R.id.category_product_price); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + Product product = productList.get(position); + Log.i("product", "getView: "+product.toString()); + if (product != null) { + viewHolder.productImage.setBackgroundResource(product.getImageUrlId()); + viewHolder.productName.setText(product.getProductName()); + viewHolder.productPrice.setText(String.valueOf(product.getProductPrice())); + } + return convertView; + } + + class ViewHolder { + ImageView productImage; + TextView productName, productPrice; + } +} diff --git a/app/src/main/java/com/example/register/dateoperation/Database.java b/app/src/main/java/com/example/register/dateoperation/Database.java new file mode 100644 index 0000000..1f96404 --- /dev/null +++ b/app/src/main/java/com/example/register/dateoperation/Database.java @@ -0,0 +1,85 @@ +package com.example.register.dateoperation; + +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, "orange", null, 1); + } + + @Override + public void onCreate(SQLiteDatabase db) { + //创建用户表 + String sql = "create table orange_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50))"; + db.execSQL(sql); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + } + + /** + * 插入数据 + * + * @param sqLiteDatabase + * @param username + * @param password + * @param sex + * @param city + */ + public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city) { + ContentValues contentValues = new ContentValues(); + contentValues.put("username", username); + contentValues.put("password", password); + contentValues.put("sex", sex); + contentValues.put("city", city); + sqLiteDatabase.insert("orange_user", null, contentValues); + sqLiteDatabase.close(); + } + + /** + * 更新数据 + */ + public void update(SQLiteDatabase sqLiteDatabase,int id,String username,String passwd,String sex,int age){ + //创建一个ContentValues对象 + ContentValues values = new ContentValues(); + //以键值对的形式插入 + values.put("username",username); + values.put("passwd",passwd); + values.put("sex",sex); + values.put("age",age); + //执行修改方法 + sqLiteDatabase.update("user",values,"id=?",new String[]{id+""} ); + sqLiteDatabase.close(); + } + + + /** + * 查询数据 + * + * @param sqLiteDatabase + * @param bundle + * @return + */ + public Bundle queryUserInfo(SQLiteDatabase sqLiteDatabase, Bundle bundle) { + String username = bundle.getString("username"); + Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=?", new String[]{username}); + if (cursor != null) { + while (cursor.moveToNext()) { + bundle.putString("sex", cursor.getString(3)); + bundle.putString("city", cursor.getString(4)); + } + } + cursor.close(); + sqLiteDatabase.close(); + return bundle; + } +} diff --git a/app/src/main/java/com/example/register/entity/Product.java b/app/src/main/java/com/example/register/entity/Product.java index f03fa1e..a45a9a7 100644 --- a/app/src/main/java/com/example/register/entity/Product.java +++ b/app/src/main/java/com/example/register/entity/Product.java @@ -28,7 +28,13 @@ public class Product { this.imageUrlId = imageUrlId; } + // public String getCharacterStory(){ return characterStory;} + + //public void setCharacterStory(String characterStory){ + // this.characterStory=characterStory; + //} private Integer imageUrlId; private String productName; private BigDecimal productPrice; + // private String characterStory; } diff --git a/app/src/main/java/com/example/register/fragment/IndexFragment.java b/app/src/main/java/com/example/register/fragment/IndexFragment.java new file mode 100644 index 0000000..1115ace --- /dev/null +++ b/app/src/main/java/com/example/register/fragment/IndexFragment.java @@ -0,0 +1,109 @@ +package com.example.register.fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.GridView; +import android.widget.LinearLayout; +import android.widget.SearchView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.register.adapter.ProductAdapter; +import com.example.register.entity.Product; +import com.example.register.R; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +public class IndexFragment extends Fragment implements View.OnClickListener { + private SearchView searchView; + private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine; + private GridView gridView; + private List productList; + private ProductAdapter productAdapter; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false); + init(view); + return view; + } + + /** + * 初始化组件 + */ + private void init(View view) { + searchView = view.findViewById(R.id.searchView); + searchView.setOnClickListener(this); + orangeLine = view.findViewById(R.id.chengzi); + orangeLine.setOnClickListener(this); + youziLine = view.findViewById(R.id.youzi); + youziLine.setOnClickListener(this); + juziLine = view.findViewById(R.id.juzi); + juziLine.setOnClickListener(this); + xiguaLine = view.findViewById(R.id.xigua); + xiguaLine.setOnClickListener(this); + liLine = view.findViewById(R.id.li); + liLine.setOnClickListener(this); + lemonLine = view.findViewById(R.id.lemon); + lemonLine.setOnClickListener(this); + mangguoLine = view.findViewById(R.id.mangguo); + mangguoLine.setOnClickListener(this); + appleLine = view.findViewById(R.id.apple); + appleLine.setOnClickListener(this); + gridView = view.findViewById(R.id.index_famous_gridview); + initData(); + productAdapter = new ProductAdapter(getActivity(), productList); + gridView.setAdapter(productAdapter); + } + + + @Override + public void onClick(View v) { + + } + + /** + * 初始化商品数据 + */ + private void initData() { + productList = new ArrayList<>(); + Product product = new Product(); + product.setImageUrlId(R.drawable.juzip); + product.setProductName("橘子"); + product.setProductPrice(new BigDecimal("9.9")); + Product product1 = new Product(); + product1.setImageUrlId(R.drawable.orange); + product1.setProductName("橙子"); + product1.setProductPrice(new BigDecimal("29.9")); + Product product2 = new Product(); + product2.setImageUrlId(R.drawable.youzip); + product2.setProductName("柚子"); + product2.setProductPrice(new BigDecimal("19.9")); + Product product3 = new Product(); + product3.setImageUrlId(R.drawable.xiguap); + product3.setProductName("西瓜"); + product3.setProductPrice(new BigDecimal("19.9")); + Product product4 = new Product(); + product4.setImageUrlId(R.drawable.applep); + product4.setProductName("苹果"); + product4.setProductPrice(new BigDecimal("49.9")); + Product product5 = new Product(); + product5.setImageUrlId(R.drawable.lemonp); + product5.setProductName("柠檬"); + product5.setProductPrice(new BigDecimal("9.9")); + productList.add(product); + productList.add(product1); + productList.add(product2); + productList.add(product3); + productList.add(product4); + productList.add(product5); + + } +} diff --git a/app/src/main/java/com/example/register/fragment/PearsonFragment.java b/app/src/main/java/com/example/register/fragment/PearsonFragment.java new file mode 100644 index 0000000..9f3cf51 --- /dev/null +++ b/app/src/main/java/com/example/register/fragment/PearsonFragment.java @@ -0,0 +1,64 @@ +package com.example.register.fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.register.R; + +public class PearsonFragment extends Fragment implements View.OnClickListener { + private ImageView userIconImage; + private TextView usernameText, userSexText, userCityText; + private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine; + + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.user, container, false); + init(view); + return view; + } + + /** + * 组件初始化 + */ + private void init(View view) { + userIconImage = view.findViewById(R.id.user_face); + usernameText = view.findViewById(R.id.login_name); + userSexText = view.findViewById(R.id.reg_sex); + userCityText = view.findViewById(R.id.reg_address); + usernameLine = view.findViewById(R.id.login_name_line); + userSexline = view.findViewById(R.id.reg_sex_line); + userCityLine = view.findViewById(R.id.reg_address_line); + userPayLine = view.findViewById(R.id.redbag_line); + userSettingLine = view.findViewById(R.id.user_setting); + //userGeneralLine = view.findViewById(R.id.user_general); + setData(); + } + + /** + * 组件赋值 + */ + private void setData() { + Bundle bundle = getArguments(); + usernameText.setText(String.format("用户名:%s", bundle.getString("username"))); + userSexText.setText(String.format("性别:%s", bundle.getString("sex"))); + userCityText.setText(String.format("城市:%s", bundle.getString("city"))); + } + + @Override + public void onClick(View v) { + + } + + +} diff --git a/app/src/main/java/com/example/register/fragment/ProductFragment.java b/app/src/main/java/com/example/register/fragment/ProductFragment.java new file mode 100644 index 0000000..04d41a8 --- /dev/null +++ b/app/src/main/java/com/example/register/fragment/ProductFragment.java @@ -0,0 +1,21 @@ +package com.example.register.fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.register.R; + +public class ProductFragment extends Fragment { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_product, container, false); + return view; + } +} diff --git a/app/src/main/java/com/example/register/fragment/SetDetailFragment.java b/app/src/main/java/com/example/register/fragment/SetDetailFragment.java index cbfbcdd..9935299 100644 --- a/app/src/main/java/com/example/register/fragment/SetDetailFragment.java +++ b/app/src/main/java/com/example/register/fragment/SetDetailFragment.java @@ -15,13 +15,14 @@ import androidx.annotation.Nullable; import com.example.register.R; import com.example.register.CategoryActivity; +import com.example.register.entity.Product; import java.util.Objects; public class SetDetailFragment extends Fragment { private View view; private ImageView imageView; - private TextView nameText, priceText; + private TextView nameText, priceText,storyText; @SuppressLint("SetTextI18n") @Nullable @@ -32,12 +33,16 @@ public class SetDetailFragment extends Fragment { init(); } CategoryActivity categoryActivity = (CategoryActivity) getActivity(); - Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> { - Log.i("sss", "onCreateView: " + product.getProductName()); - imageView.setBackgroundResource(product.getImageUrlId()); - nameText.setText(product.getProductName()); - priceText.setText(product.getProductPrice().toString()); + categoryActivity.setOnChangeListener(new CategoryActivity.OnChangeListener() { + @Override + public void changeText(Product product) { + imageView.setBackgroundResource(product.getImageUrlId()); + nameText.setText(product.getProductName()); + priceText.setText(product.getProductPrice().toString()); + + } }); + return view; } @@ -47,7 +52,8 @@ public class SetDetailFragment extends Fragment { private void init() { imageView = view.findViewById(R.id.category_product_image); nameText = view.findViewById(R.id.category_product_name); - priceText = view.findViewById(R.id.category_product_price); + priceText = view.findViewById(R.id.category_product_price); + } } diff --git a/app/src/main/java/com/example/register/fragment/ShoppingCartFragment.java b/app/src/main/java/com/example/register/fragment/ShoppingCartFragment.java new file mode 100644 index 0000000..6229019 --- /dev/null +++ b/app/src/main/java/com/example/register/fragment/ShoppingCartFragment.java @@ -0,0 +1,21 @@ +package com.example.register.fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.register.R; + +public class ShoppingCartFragment extends Fragment { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_shopping, container, false); + return view; + } +} diff --git a/app/src/main/java/com/example/register/loginActivity.java b/app/src/main/java/com/example/register/loginActivity.java index eceae00..fc521b2 100644 --- a/app/src/main/java/com/example/register/loginActivity.java +++ b/app/src/main/java/com/example/register/loginActivity.java @@ -1,18 +1,24 @@ package com.example.register; - - import android.content.Intent; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; +import android.view.View; import android.widget.Button; import android.widget.EditText; -import android.util.Log; +import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; -public class loginActivity extends AppCompatActivity { +import com.example.register.IndexActivity; +import com.example.register.registerActivity; +import com.example.register.dateoperation.Database; + + +public class loginActivity extends AppCompatActivity implements View.OnClickListener { Button login, register; - EditText username, password; + EditText usernameT, passwordT; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -20,8 +26,8 @@ public class loginActivity extends AppCompatActivity { //对应xml文件中组件的连接 login = findViewById(R.id.login); register = findViewById(R.id.register); - username = findViewById(R.id.username); - password = findViewById(R.id.password); + usernameT = findViewById(R.id.username); + passwordT = findViewById(R.id.password); login.setOnClickListener(view -> { Intent intent = new Intent(); @@ -34,4 +40,46 @@ public class loginActivity extends AppCompatActivity { startActivity(intent); }); } + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.register: + Intent intent = new Intent(loginActivity.this, registerActivity.class); + startActivity(intent); + break; + case R.id.login: + //注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示 + if (validateLogin()) { + Intent intent1 = new Intent(loginActivity.this, IndexActivity.class); + Bundle bundle = new Bundle(); + Database database = new Database(loginActivity.this); + bundle.putString("username", usernameT.getText().toString()); + bundle = database.queryUserInfo(database.getReadableDatabase(), bundle); + intent1.putExtras(bundle); + startActivity(intent1); + } else { + Toast.makeText(loginActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show(); + } + break; + } + } + /** + * 登录验证 + * + * @return + */ + private boolean validateLogin() { + String username = usernameT.getText().toString(); + String password = passwordT.getText().toString(); + Database database = new Database(loginActivity.this); + SQLiteDatabase sqLiteDatabase = database.getReadableDatabase(); + Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=? and password=?", new String[]{username, password}); + if (cursor.getCount() > 0) { + return true; + } + return false; + } + + + } \ No newline at end of file diff --git a/app/src/main/java/com/example/register/registerActivity.java b/app/src/main/java/com/example/register/registerActivity.java index 10d4a1d..e7acb7d 100644 --- a/app/src/main/java/com/example/register/registerActivity.java +++ b/app/src/main/java/com/example/register/registerActivity.java @@ -1,20 +1,22 @@ package com.example.register; import androidx.appcompat.app.AppCompatActivity; +import android.content.ContentValues; import android.content.Intent; +import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.graphics.Color; import com.lljjcoder.citypickerview.widget.CityPicker; - +import androidx.annotation.Nullable; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; - - +import com.example.register.R; +import com.example.register.dateoperation.Database; public class registerActivity extends AppCompatActivity implements View.OnClickListener { private EditText usernameEdit, passwordEdit, surePasswordEdit; @@ -159,5 +161,22 @@ public class registerActivity extends AppCompatActivity implements View.OnClickL } - + /** + * 插入数据库的值 + * + * @param sqLiteDatabase + * @param bundle + */ + private void insertData(SQLiteDatabase sqLiteDatabase, Bundle bundle) { + ContentValues contentValues = new ContentValues(); + contentValues.put("username", bundle.getString("usernameT")); + contentValues.put("password", bundle.getString("passwordT")); + contentValues.put("sex", bundle.getString("sex")); + contentValues.put("city", bundle.getString("city")); + sqLiteDatabase.insert("orange_user", null, contentValues); + sqLiteDatabase.close(); + } } + + + diff --git a/app/src/main/java/com/example/register/userActivity.java b/app/src/main/java/com/example/register/userActivity.java index 828ec7d..9c3bb8b 100644 --- a/app/src/main/java/com/example/register/userActivity.java +++ b/app/src/main/java/com/example/register/userActivity.java @@ -1,4 +1,5 @@ package com.example.register; +import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; @@ -81,7 +82,7 @@ public class userActivity extends AppCompatActivity implements View.OnClickListe } @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { switch (v.getId()) { case R.id.user_searchProduct: Intent intent1 = new Intent(userActivity.this, CategoryActivity.class); diff --git a/app/src/main/res/drawable/apple.png b/app/src/main/res/drawable/apple.png new file mode 100644 index 0000000..0810381 Binary files /dev/null and b/app/src/main/res/drawable/apple.png differ diff --git a/app/src/main/res/drawable/applep.png b/app/src/main/res/drawable/applep.png new file mode 100644 index 0000000..e26da47 Binary files /dev/null and b/app/src/main/res/drawable/applep.png differ diff --git a/app/src/main/res/drawable/arrow_right.png b/app/src/main/res/drawable/arrow_right.png new file mode 100644 index 0000000..84ded85 Binary files /dev/null and b/app/src/main/res/drawable/arrow_right.png differ diff --git a/app/src/main/res/drawable/chengzi.png b/app/src/main/res/drawable/chengzi.png new file mode 100644 index 0000000..fff0306 Binary files /dev/null and b/app/src/main/res/drawable/chengzi.png differ diff --git a/app/src/main/res/drawable/index.png b/app/src/main/res/drawable/index.png new file mode 100644 index 0000000..cc1ec04 Binary files /dev/null and b/app/src/main/res/drawable/index.png differ diff --git a/app/src/main/res/drawable/index_menu.xml b/app/src/main/res/drawable/index_menu.xml new file mode 100644 index 0000000..14636dd --- /dev/null +++ b/app/src/main/res/drawable/index_menu.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/juzi.png b/app/src/main/res/drawable/juzi.png new file mode 100644 index 0000000..106df92 Binary files /dev/null and b/app/src/main/res/drawable/juzi.png differ diff --git a/app/src/main/res/drawable/juzip.png b/app/src/main/res/drawable/juzip.png new file mode 100644 index 0000000..4f10b72 Binary files /dev/null and b/app/src/main/res/drawable/juzip.png differ diff --git a/app/src/main/res/drawable/lemon.png b/app/src/main/res/drawable/lemon.png new file mode 100644 index 0000000..39f12cc Binary files /dev/null and b/app/src/main/res/drawable/lemon.png differ diff --git a/app/src/main/res/drawable/lemonp.png b/app/src/main/res/drawable/lemonp.png new file mode 100644 index 0000000..ca5eca8 Binary files /dev/null and b/app/src/main/res/drawable/lemonp.png differ diff --git a/app/src/main/res/drawable/li.png b/app/src/main/res/drawable/li.png new file mode 100644 index 0000000..0834592 Binary files /dev/null and b/app/src/main/res/drawable/li.png differ diff --git a/app/src/main/res/drawable/mangguo.png b/app/src/main/res/drawable/mangguo.png new file mode 100644 index 0000000..2e9825c Binary files /dev/null and b/app/src/main/res/drawable/mangguo.png differ diff --git a/app/src/main/res/drawable/orange.png b/app/src/main/res/drawable/orange.png new file mode 100644 index 0000000..70e8db8 Binary files /dev/null and b/app/src/main/res/drawable/orange.png differ diff --git a/app/src/main/res/drawable/pearson.png b/app/src/main/res/drawable/pearson.png new file mode 100644 index 0000000..90cf0eb Binary files /dev/null and b/app/src/main/res/drawable/pearson.png differ diff --git a/app/src/main/res/drawable/product.png b/app/src/main/res/drawable/product.png new file mode 100644 index 0000000..8f5cb21 Binary files /dev/null and b/app/src/main/res/drawable/product.png differ diff --git a/app/src/main/res/drawable/shoppingcart.png b/app/src/main/res/drawable/shoppingcart.png new file mode 100644 index 0000000..76c06de Binary files /dev/null and b/app/src/main/res/drawable/shoppingcart.png differ diff --git a/app/src/main/res/drawable/shuiguo.png b/app/src/main/res/drawable/shuiguo.png new file mode 100644 index 0000000..d316137 Binary files /dev/null and b/app/src/main/res/drawable/shuiguo.png differ diff --git a/app/src/main/res/drawable/xigua.png b/app/src/main/res/drawable/xigua.png new file mode 100644 index 0000000..20275c1 Binary files /dev/null and b/app/src/main/res/drawable/xigua.png differ diff --git a/app/src/main/res/drawable/xiguap.png b/app/src/main/res/drawable/xiguap.png new file mode 100644 index 0000000..b760712 Binary files /dev/null and b/app/src/main/res/drawable/xiguap.png differ diff --git a/app/src/main/res/drawable/youzi.png b/app/src/main/res/drawable/youzi.png new file mode 100644 index 0000000..53df959 Binary files /dev/null and b/app/src/main/res/drawable/youzi.png differ diff --git a/app/src/main/res/drawable/youzip.png b/app/src/main/res/drawable/youzip.png new file mode 100644 index 0000000..5a7d966 Binary files /dev/null and b/app/src/main/res/drawable/youzip.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..65a59d5 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/categoty_detail_content.xml b/app/src/main/res/layout/categoty_detail_content.xml index a46be2c..0349e95 100644 --- a/app/src/main/res/layout/categoty_detail_content.xml +++ b/app/src/main/res/layout/categoty_detail_content.xml @@ -28,4 +28,6 @@ android:gravity="center" android:textColor="#050505" android:textSize="16sp" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_index.xml b/app/src/main/res/layout/content_index.xml new file mode 100644 index 0000000..7fa926d --- /dev/null +++ b/app/src/main/res/layout/content_index.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_nav.xml b/app/src/main/res/layout/content_nav.xml new file mode 100644 index 0000000..2b6b43b --- /dev/null +++ b/app/src/main/res/layout/content_nav.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_product.xml b/app/src/main/res/layout/content_product.xml new file mode 100644 index 0000000..c946607 --- /dev/null +++ b/app/src/main/res/layout/content_product.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_shopping.xml b/app/src/main/res/layout/content_shopping.xml new file mode 100644 index 0000000..e152fbb --- /dev/null +++ b/app/src/main/res/layout/content_shopping.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/index_famous.xml b/app/src/main/res/layout/index_famous.xml new file mode 100644 index 0000000..b884b44 --- /dev/null +++ b/app/src/main/res/layout/index_famous.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/register.xml b/app/src/main/res/layout/register.xml index c11f996..1eed6a5 100644 --- a/app/src/main/res/layout/register.xml +++ b/app/src/main/res/layout/register.xml @@ -93,7 +93,7 @@ android:layout_width="290dp" android:layout_height="60dp" android:textAlignment="center" - android:maxLength="10" + android:maxLength="16" android:maxLines="1" android:hint="确认密码"/> diff --git a/app/src/main/res/layout/user.xml b/app/src/main/res/layout/user.xml index b10bae2..720c91d 100644 --- a/app/src/main/res/layout/user.xml +++ b/app/src/main/res/layout/user.xml @@ -12,6 +12,7 @@ android:orientation="vertical">