diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 61a9130..fb7f4a8 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index ee22109..37612a4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -69,7 +69,7 @@
-
+
diff --git a/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java b/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
index 7e81702..e16eb0b 100644
--- a/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
+++ b/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
@@ -1,62 +1,121 @@
package com.orangesale.cn.activity;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.FragmentTransaction;
-
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
-import android.view.View;
+import android.view.ViewTreeObserver;
import android.widget.LinearLayout;
-
+import androidx.annotation.Nullable;
+import androidx.fragment.app.FragmentTransaction;
import com.orangesale.cn.R;
+import android.view.View;
+import com.orangesale.cn.fragment.IndexFragment;
+import com.orangesale.cn.fragment.PersonFragment;
+import com.orangesale.cn.fragment.ProductFragment;
+import com.orangesale.cn.fragment.ShoppingFragment;
+
+public class IndexActivity extends Activity implements ViewTreeObserver.OnDrawListener {
+ private IndexFragment indexFragment;
+ private ProductFragment productFragment;
+ private ShoppingFragment shoppingFragment;
+ private PersonFragment personFragment;
-public class IndexActivity extends Activity implements View.OnClickListener {
- private LinearLayout indexLine;
- //private ProductFragment productFragment;
+ private LinearLayout indexLine, productLine, shoppingLine, personLine;
@Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
+ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_index);
+ setContentView(R.layout.activity_main);
init();
initIndexFragment();
}
- //组件初始化
- private void init(){
+
+ private void init() {
+ indexLine = findViewById(R.id.content_index);
+ indexLine.setOnClickListener(this);
+
+ indexLine = findViewById(R.id.content_product);
+ productLine.setOnClickListener(this);
+
+ indexLine = findViewById(R.id.content_cart);
+ shoppingLine.setOnClickListener(this);
+
+ indexLine = findViewById(R.id.content_person);
+ productLine.setOnClickListener(this);
+
}
@Override
- public void onClick(View v){
- switch (v.getId()){
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.content_index:
+ initIndexFragment();
+ break;
- }
- }
+ case R.id.content_product:
+ initproductFragment();
+ break;
- //初始化首页Fragment
- private void initIndexFragment(){
- /*
- FragmentTransaction transaction=getFragmentManager().beginTransaction();
- if(indexFragment==null){
+ case R.id.content_cart:
+ initshoppingFragment();
+ break;
+ case R.id.content_person:
+ //注册验证方法
+ initpersonFragment();
+ break;
}
- */
}
- //初始化产品fragment
- private void initproductFragment(){
+ private void initIndexFragment() {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (indexFragment == null) {
+ indexFragment = new IndexFragment();
+ transaction.replace(R.id.main_content, indexFragment);
+ transaction.commit();
+ }
- }
+ private void initproductFragment() {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (productFragment == null) {
+ productFragment = new ProductFragment();
+ }
+ transaction.replace(R.id.main_content, productFragment);
+ transaction.commit();
+ }
+
+ private void initshoppingCartFragment() {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (shoppingFragment == null) {
+ shoppingFragment = new ShoppingFragment();
+ }
+ transaction.replace(R.id.main_content, shoppingFragment);
+ transaction.commit();
+ }
+
+ private void initpersonFragment() {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ if (personFragment == null) {
+ Intent intent = IndexActivity.this.getIntent();
+ Bundle bundle = intent.getExtras();
+ personFragment = new PersonFragment();
+ personFragment.setArguments(bundle);
+ }
+ transaction.replace(R.id.main_content, personFragment);
+ transaction.commit();
+ }
+
+ }
- //初始化购物车fragment
- private void initshoppingCarFragment(){
+ @Override
+ public void onDraw() {
}
+}
+
- //初始化个人fragment
- private void initpersonFragment(){
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java b/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
new file mode 100644
index 0000000..3931a0a
--- /dev/null
+++ b/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
@@ -0,0 +1,57 @@
+package com.orangesale.cn.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 com.orangesale.cn.R;
+import com.orangesale.cn.adapter.Adapter;
+import com.orangesale.cn.entity.Product;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class IndexFragment extends Fragment implements View.OnClickListener {
+ private SearchView searchView;
+ private LinearLayout bingtangchengLine;
+ private GridView gridView;
+ private Adapter adapter;
+ private List productList;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, 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);
+ initData();
+ adapter = new Adapter(getActivity(),productList);
+ gridView.setAdapter(adapter);
+ }
+ @Override
+ public void initData(){
+ productList = new ArrayList<>();
+ Product product = new Product();
+ product.setImageUrlId(R.drawable.bingtangcheng);
+ product.setProductName("冰糖橙");
+ product.setProductPrice(new BigDecimal("9.9"));
+
+ Product product1 = new Product();
+ product1.setImageUrlId(R.drawable.chucheng);
+ product1.setProductName("褚橙");
+ product1.setProductPrice(new BigDecimal("29.9"));
+
+ productList.add(product);
+ productList.add(product1);
+ }
+
+
+
+
+}
diff --git a/app/src/main/java/com/orangesale/cn/fragment/PersonFragment.java b/app/src/main/java/com/orangesale/cn/fragment/PersonFragment.java
new file mode 100644
index 0000000..f4f0f72
--- /dev/null
+++ b/app/src/main/java/com/orangesale/cn/fragment/PersonFragment.java
@@ -0,0 +1,70 @@
+package com.orangesale.cn.fragment;
+
+import android.os.Bundle;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.orangesale.cn.R;
+
+import android.app.Fragment;
+
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+
+
+public class PersonFragment 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.content_user, container, false);
+ init(view);
+ return view;
+ }
+
+ /**
+ * 组件初始化
+ */
+ private void init(View view) {
+ userIconImage = view.findViewById(R.id.user_icon);
+ usernameText = view.findViewById(R.id.user_username);
+ userSexText = view.findViewById(R.id.user_sex);
+ userCityText = view.findViewById(R.id.user_city);
+ usernameLine = view.findViewById(R.id.user_username_line);
+ userSexline = view.findViewById(R.id.user_sex_line);
+ userCityLine = view.findViewById(R.id.user_city_line);
+ userPayLine = view.findViewById(R.id.user_pay);
+ 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) {
+
+ }
+
+
+}
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java b/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java
new file mode 100644
index 0000000..2b9c096
--- /dev/null
+++ b/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java
@@ -0,0 +1,23 @@
+package com.orangesale.cn.fragment;
+
+
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.orangesale.cn.R;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+
+
+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/orangesale/cn/fragment/SetDetailFragment.java b/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
index 3ba48dc..d124d5e 100644
--- a/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
+++ b/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
@@ -38,7 +38,6 @@ 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());
diff --git a/app/src/main/java/com/orangesale/cn/fragment/ShoppingFragment.java b/app/src/main/java/com/orangesale/cn/fragment/ShoppingFragment.java
new file mode 100644
index 0000000..5ae056c
--- /dev/null
+++ b/app/src/main/java/com/orangesale/cn/fragment/ShoppingFragment.java
@@ -0,0 +1,23 @@
+package com.orangesale.cn.fragment;
+
+
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.orangesale.cn.R;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+
+
+public class ShoppingFragment 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/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/button_login.xml b/app/src/main/res/drawable/button_login.xml
index a13b012..d093f1b 100644
--- a/app/src/main/res/drawable/button_login.xml
+++ b/app/src/main/res/drawable/button_login.xml
@@ -2,7 +2,7 @@
-
-
+
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_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/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
index 23ecdef..70e8db8 100644
Binary files a/app/src/main/res/drawable/orange.png and b/app/src/main/res/drawable/orange.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/spinner_drop_down_shape.xml b/app/src/main/res/drawable/spinner_drop_down_shape.xml
index 91bf727..64306b1 100644
--- a/app/src/main/res/drawable/spinner_drop_down_shape.xml
+++ b/app/src/main/res/drawable/spinner_drop_down_shape.xml
@@ -6,7 +6,7 @@
diff --git a/app/src/main/res/drawable/tab_menu_text.xml b/app/src/main/res/drawable/tab_menu_text.xml
new file mode 100644
index 0000000..fb06945
--- /dev/null
+++ b/app/src/main/res/drawable/tab_menu_text.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/user_icon.png b/app/src/main/res/drawable/user_icon.png
index 293ad7a..d5309b1 100644
Binary files a/app/src/main/res/drawable/user_icon.png and b/app/src/main/res/drawable/user_icon.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
index 4fc2444..e9f1f4a 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,18 +1,28 @@
-
+ android:orientation="vertical"
+ tools:context=".activity.IndexActivity">
-
-
-
\ No newline at end of file
+
+
+ -->
+
+
+
+
+
+
\ 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
index 3f06d5b..d86e584 100644
--- a/app/src/main/res/layout/content_nav.xml
+++ b/app/src/main/res/layout/content_nav.xml
@@ -23,7 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="Index"
+ android:text="首页"
android:textColor="#000"
android:textSize="18sp" />
@@ -51,7 +51,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="goods"
+ android:text="商品"
android:textColor="#000"
android:textSize="18sp" />
@@ -80,7 +80,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="cart"
+ android:text="购物车"
android:textColor="#000"
android:textSize="18sp" />
@@ -110,7 +110,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="Me"
+ android:text="我"
android:textColor="#000"
android:textSize="18sp" />
diff --git a/app/src/main/res/layout/fragment_index.xml b/app/src/main/res/layout/fragment_index.xml
new file mode 100644
index 0000000..940f1f1
--- /dev/null
+++ b/app/src/main/res/layout/fragment_index.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+ />
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_person.xml b/app/src/main/res/layout/fragment_person.xml
new file mode 100644
index 0000000..c8b2375
--- /dev/null
+++ b/app/src/main/res/layout/fragment_person.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_product.xml b/app/src/main/res/layout/fragment_product.xml
new file mode 100644
index 0000000..d1054a2
--- /dev/null
+++ b/app/src/main/res/layout/fragment_product.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_shopping.xml b/app/src/main/res/layout/fragment_shopping.xml
new file mode 100644
index 0000000..5220259
--- /dev/null
+++ b/app/src/main/res/layout/fragment_shopping.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9890b9d..f3bedc8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,4 +2,6 @@
Fresh橙光果篮
用户名:
密 码:
+
+ Hello blank fragment