diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 440c300..36d689d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.9.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.legacy:legacy-support-v4:1.0.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 75a512d..92b1ee5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,8 @@ android:theme="@style/Theme.MyApplication" android:usesCleartextTraffic="true" tools:targetApi="31"> + + @@ -31,6 +33,7 @@ + diff --git a/app/src/main/java/com/example/myapplication/FindFragment.java b/app/src/main/java/com/example/myapplication/FindFragment.java index e49ec91..6f22a8d 100644 --- a/app/src/main/java/com/example/myapplication/FindFragment.java +++ b/app/src/main/java/com/example/myapplication/FindFragment.java @@ -8,53 +8,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -/** - * A simple {@link Fragment} subclass. - * Use the {@link FindFragment#newInstance} factory method to - * create an instance of this fragment. - */ + public class FindFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public FindFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment FindFragment. - */ - // TODO: Rename and change types and number of parameters - public static FindFragment newInstance(String param1, String param2) { - FindFragment fragment = new FindFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/com/example/myapplication/MainActivity.java b/app/src/main/java/com/example/myapplication/MainActivity.java index 0109c01..5ed0f83 100644 --- a/app/src/main/java/com/example/myapplication/MainActivity.java +++ b/app/src/main/java/com/example/myapplication/MainActivity.java @@ -56,7 +56,7 @@ public class MainActivity extends AppCompatActivity { SharedPreferences.Editor editor = getSharedPreferences("data", MODE_PRIVATE).edit(); editor.putString("token", loginResult.token); editor.apply(); - Intent intent = new Intent(MainActivity.this, MineFragment.class); + Intent intent = new Intent(MainActivity.this, yindaoActivity.class); startActivity(intent); }else { Toast.makeText(MainActivity.this,loginResult.msg, Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/example/myapplication/MineFragment.java b/app/src/main/java/com/example/myapplication/MineFragment.java index 7abdbb1..207297f 100644 --- a/app/src/main/java/com/example/myapplication/MineFragment.java +++ b/app/src/main/java/com/example/myapplication/MineFragment.java @@ -7,54 +7,7 @@ import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - -/** - * A simple {@link Fragment} subclass. - * Use the {@link MineFragment#newInstance} factory method to - * create an instance of this fragment. - */ public class MineFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public MineFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment MineFragment. - */ - // TODO: Rename and change types and number of parameters - public static MineFragment newInstance(String param1, String param2) { - MineFragment fragment = new MineFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java b/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java index 945b963..960c275 100644 --- a/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java +++ b/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java @@ -8,53 +8,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -/** - * A simple {@link Fragment} subclass. - * Use the {@link ShoppingTrolleyFragment#newInstance} factory method to - * create an instance of this fragment. - */ + public class ShoppingTrolleyFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public ShoppingTrolleyFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment ShoppingTrolleyFragment. - */ - // TODO: Rename and change types and number of parameters - public static ShoppingTrolleyFragment newInstance(String param1, String param2) { - ShoppingTrolleyFragment fragment = new ShoppingTrolleyFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/com/example/myapplication/VipFragment.java b/app/src/main/java/com/example/myapplication/VipFragment.java index 13aabc5..bce6d99 100644 --- a/app/src/main/java/com/example/myapplication/VipFragment.java +++ b/app/src/main/java/com/example/myapplication/VipFragment.java @@ -8,53 +8,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -/** - * A simple {@link Fragment} subclass. - * Use the {@link VipFragment#newInstance} factory method to - * create an instance of this fragment. - */ public class VipFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public VipFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment VipFragment. - */ - // TODO: Rename and change types and number of parameters - public static VipFragment newInstance(String param1, String param2) { - VipFragment fragment = new VipFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/com/example/myapplication/yindaoActivity.java b/app/src/main/java/com/example/myapplication/yindaoActivity.java index aa2b8bb..9fecee9 100644 --- a/app/src/main/java/com/example/myapplication/yindaoActivity.java +++ b/app/src/main/java/com/example/myapplication/yindaoActivity.java @@ -3,6 +3,8 @@ package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; +import android.view.View; +import android.widget.ImageButton; public class yindaoActivity extends AppCompatActivity { @@ -17,15 +19,86 @@ public class yindaoActivity extends AppCompatActivity { ShoppingTrolleyFragment shoppingTrolleyFragment = new ShoppingTrolleyFragment(); MineFragment mineFragment = new MineFragment(); - getSupportFragmentManager().beginTransaction().replace(R.id.constraintLayout9,homeFragment).commit(); - getSupportFragmentManager().beginTransaction().replace(R.id.constraintLayout9,findFragment).commit(); - getSupportFragmentManager().beginTransaction().replace(R.id.constraintLayout9,vipFragment).commit(); - getSupportFragmentManager().beginTransaction().replace(R.id.constraintLayout9,shoppingTrolleyFragment).commit(); - getSupportFragmentManager().beginTransaction().replace(R.id.constraintLayout9,mineFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.constraintLayout100,homeFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.constraintLayout100,findFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.constraintLayout100,vipFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.constraintLayout100,shoppingTrolleyFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.constraintLayout100,mineFragment).commit(); //默认第一个,显示第一个 getSupportFragmentManager().beginTransaction() - .hide(findFragment).hide(vipFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(shoppingTrolleyFragment).commit(); + .hide(findFragment).hide(vipFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(homeFragment).commit(); + + ImageButton imageButton1 = findViewById(R.id.imageButton4); + ImageButton imageButton2 = findViewById(R.id.imageButton5); + ImageButton imageButton3 = findViewById(R.id.imageButton6); + ImageButton imageButton4 = findViewById(R.id.imageButton7); + ImageButton imageButton5 = findViewById(R.id.imageButton8); + + imageButton1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSupportFragmentManager().beginTransaction() + .hide(findFragment).hide(vipFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(homeFragment).commit(); + imageButton1.setSelected(true); + imageButton2.setSelected(false); + imageButton3.setSelected(false); + imageButton4.setSelected(false); + imageButton5.setSelected(false); + } + }); + + imageButton2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSupportFragmentManager().beginTransaction() + .hide(homeFragment).hide(vipFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(findFragment).commit(); + imageButton1.setSelected(false); + imageButton2.setSelected(true); + imageButton3.setSelected(false); + imageButton4.setSelected(false); + imageButton5.setSelected(false); + } + }); + + imageButton3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSupportFragmentManager().beginTransaction() + .hide(homeFragment).hide(findFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(vipFragment).commit(); + imageButton1.setSelected(false); + imageButton2.setSelected(false); + imageButton3.setSelected(true); + imageButton4.setSelected(false); + imageButton5.setSelected(false); + } + }); + + imageButton4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSupportFragmentManager().beginTransaction() + .hide(homeFragment).hide(findFragment).hide(vipFragment).hide(mineFragment).show(shoppingTrolleyFragment).commit(); + imageButton1.setSelected(false); + imageButton2.setSelected(false); + imageButton3.setSelected(false); + imageButton4.setSelected(true); + imageButton5.setSelected(false); + } + }); + + imageButton5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSupportFragmentManager().beginTransaction() + .hide(homeFragment).hide(findFragment).hide(vipFragment).hide(shoppingTrolleyFragment).show(mineFragment).commit(); + imageButton1.setSelected(false); + imageButton2.setSelected(false); + imageButton3.setSelected(false); + imageButton4.setSelected(false); + imageButton5.setSelected(true); + } + }); } } \ No newline at end of file diff --git a/app/src/main/res/drawable/chakandingdan.png b/app/src/main/res/drawable/chakandingdan.png new file mode 100644 index 0000000..7bcb95d Binary files /dev/null and b/app/src/main/res/drawable/chakandingdan.png differ diff --git a/app/src/main/res/drawable/daifukuan.png b/app/src/main/res/drawable/daifukuan.png new file mode 100644 index 0000000..ae2674b Binary files /dev/null and b/app/src/main/res/drawable/daifukuan.png differ diff --git a/app/src/main/res/drawable/daipeisong.png b/app/src/main/res/drawable/daipeisong.png new file mode 100644 index 0000000..29c40b1 Binary files /dev/null and b/app/src/main/res/drawable/daipeisong.png differ diff --git a/app/src/main/res/drawable/daitihuo.png b/app/src/main/res/drawable/daitihuo.png new file mode 100644 index 0000000..102b789 Binary files /dev/null and b/app/src/main/res/drawable/daitihuo.png differ diff --git a/app/src/main/res/drawable/faxiantupian.xml b/app/src/main/res/drawable/faxiantupian.xml new file mode 100644 index 0000000..ea1239d --- /dev/null +++ b/app/src/main/res/drawable/faxiantupian.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gouwuchetupian.xml b/app/src/main/res/drawable/gouwuchetupian.xml new file mode 100644 index 0000000..e70cb34 --- /dev/null +++ b/app/src/main/res/drawable/gouwuchetupian.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/huiyuantupian.xml b/app/src/main/res/drawable/huiyuantupian.xml new file mode 100644 index 0000000..a27c90a --- /dev/null +++ b/app/src/main/res/drawable/huiyuantupian.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shouyetupian.xml b/app/src/main/res/drawable/shouyetupian.xml new file mode 100644 index 0000000..7deb6d7 --- /dev/null +++ b/app/src/main/res/drawable/shouyetupian.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tihuoerweima.png b/app/src/main/res/drawable/tihuoerweima.png new file mode 100644 index 0000000..a8608fa Binary files /dev/null and b/app/src/main/res/drawable/tihuoerweima.png differ diff --git a/app/src/main/res/drawable/wodetupian.xml b/app/src/main/res/drawable/wodetupian.xml new file mode 100644 index 0000000..1172b37 --- /dev/null +++ b/app/src/main/res/drawable/wodetupian.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_yindao.xml b/app/src/main/res/layout/activity_yindao.xml index 2bb2fec..7dfccaf 100644 --- a/app/src/main/res/layout/activity_yindao.xml +++ b/app/src/main/res/layout/activity_yindao.xml @@ -38,7 +38,7 @@ android:id="@+id/imageButton4" android:layout_width="81dp" android:layout_height="98dp" - android:src="@drawable/shouye1" + android:src="@drawable/shouyetupian" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -57,7 +57,7 @@ android:id="@+id/imageButton5" android:layout_width="72dp" android:layout_height="96dp" - android:src="@drawable/faxian1" + android:src="@drawable/faxiantupian" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -77,7 +77,7 @@ android:id="@+id/imageButton6" android:layout_width="72dp" android:layout_height="96dp" - android:src="@drawable/huiyuan1" + android:src="@drawable/huiyuantupian" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -97,7 +97,7 @@ android:id="@+id/imageButton7" android:layout_width="84dp" android:layout_height="96dp" - android:src="@drawable/gouwuche1" + android:src="@drawable/gouwuchetupian" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -117,7 +117,7 @@ android:id="@+id/imageButton8" android:layout_width="74dp" android:layout_height="96dp" - android:src="@drawable/wode1" + android:src="@drawable/wodetupian" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -127,6 +127,7 @@ + app:layout_constraintStart_toStartOf="parent"> @@ -56,12 +55,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="180dp" - android:text="关注" - android:gravity="center" - android:textStyle="bold" - android:textSize="18dp" - android:textColor="#000000" android:backgroundTint="@color/white" + android:gravity="center" + android:text="关注" + android:textColor="#000000" + android:textSize="18dp" + android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -71,21 +70,17 @@ + app:layout_constraintStart_toStartOf="parent"> + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_mine.xml b/app/src/main/res/layout/fragment_mine.xml index 37736ab..15de764 100644 --- a/app/src/main/res/layout/fragment_mine.xml +++ b/app/src/main/res/layout/fragment_mine.xml @@ -6,14 +6,13 @@ android:layout_height="match_parent" tools:context=".MineFragment"> - - - + + + +