diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 92b1ee5..a507e9a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,8 +19,15 @@ android:theme="@style/Theme.MyApplication" android:usesCleartextTraffic="true" tools:targetApi="31"> - - + + + @@ -33,7 +40,6 @@ - - + \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/MineFragment.java b/app/src/main/java/com/example/myapplication/MineFragment.java index 207297f..6aa32af 100644 --- a/app/src/main/java/com/example/myapplication/MineFragment.java +++ b/app/src/main/java/com/example/myapplication/MineFragment.java @@ -1,17 +1,56 @@ package com.example.myapplication; import android.os.Bundle; +import android.content.Intent; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.Button; + + + public class MineFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_mine, container, false); + View view = inflater.inflate(R.layout.fragment_mine, container, false); + + //咨询客服 + ImageButton imageButton = view.findViewById(R.id.imageButton18); + imageButton.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + Intent intent = new Intent(MineFragment.this.getActivity(), zixunkefuActivity.class); + startActivity(intent); + } + }); + + //等级详情 + ImageButton imageButton1 = view.findViewById(R.id.imageButton17); + imageButton1.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + Intent intent = new Intent(MineFragment.this.getActivity(), dengjixiangqingActivity.class); + startActivity(intent); + } + }); + + //去购物 + Button button = view.findViewById(R.id.button7); + button.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + Intent intent = new Intent(MineFragment.this.getActivity(), yindaoActivity.class); + intent.putExtra("homefragment","HomeFragment"); + startActivity(intent); + } + }); + + return view; } } \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/dengjixiangqingActivity.java b/app/src/main/java/com/example/myapplication/dengjixiangqingActivity.java new file mode 100644 index 0000000..9d6947f --- /dev/null +++ b/app/src/main/java/com/example/myapplication/dengjixiangqingActivity.java @@ -0,0 +1,30 @@ +package com.example.myapplication; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.view.View; +import android.content.Intent; +import android.widget.ImageButton; + +public class dengjixiangqingActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_dengjixiangqing); + + + // 返回 + ImageButton imageButton = findViewById(R.id.imageButton9); + imageButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(dengjixiangqingActivity.this,yindaoActivity.class); + intent.putExtra("fragment","MineFragment"); + startActivity(intent); + } + }); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/tuanzhangruzhuActivity.java b/app/src/main/java/com/example/myapplication/tuanzhangruzhuActivity.java new file mode 100644 index 0000000..80cba0a --- /dev/null +++ b/app/src/main/java/com/example/myapplication/tuanzhangruzhuActivity.java @@ -0,0 +1,14 @@ +package com.example.myapplication; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class tuanzhangruzhuActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_tuanzhangruzhu); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/yindaoActivity.java b/app/src/main/java/com/example/myapplication/yindaoActivity.java index 9fecee9..625dc56 100644 --- a/app/src/main/java/com/example/myapplication/yindaoActivity.java +++ b/app/src/main/java/com/example/myapplication/yindaoActivity.java @@ -5,100 +5,93 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; public class yindaoActivity extends AppCompatActivity { + private HomeFragment homeFragment; + private FindFragment findFragment; + private VipFragment vipFragment; + private ShoppingTrolleyFragment shoppingTrolleyFragment; + private MineFragment mineFragment; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_yindao); - HomeFragment homeFragment = new HomeFragment(); - FindFragment findFragment = new FindFragment(); - VipFragment vipFragment = new VipFragment(); - ShoppingTrolleyFragment shoppingTrolleyFragment = new ShoppingTrolleyFragment(); - MineFragment mineFragment = new MineFragment(); + homeFragment = new HomeFragment(); + findFragment = new FindFragment(); + vipFragment = new VipFragment(); + shoppingTrolleyFragment = new ShoppingTrolleyFragment(); + mineFragment = new MineFragment(); - 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(); + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + fragmentTransaction.add(R.id.constraintLayout100, homeFragment); + fragmentTransaction.add(R.id.constraintLayout100, findFragment); + fragmentTransaction.add(R.id.constraintLayout100, vipFragment); + fragmentTransaction.add(R.id.constraintLayout100, shoppingTrolleyFragment); + fragmentTransaction.add(R.id.constraintLayout100, mineFragment); + fragmentTransaction.commit(); - //默认第一个,显示第一个 + // 默认隐藏所有 Fragment + hideAllFragments(); + + // 根据传递的参数显示相应的 Fragment + String fragmentName = getIntent().getStringExtra("fragment"); + if ("MineFragment".equals(fragmentName)) { + showFragment(mineFragment); + } else { + showFragment(homeFragment); + } + + setupImageButtons(); + } + + private void hideAllFragments() { getSupportFragmentManager().beginTransaction() - .hide(findFragment).hide(vipFragment).hide(shoppingTrolleyFragment).hide(mineFragment).show(homeFragment).commit(); + .hide(homeFragment) + .hide(findFragment) + .hide(vipFragment) + .hide(shoppingTrolleyFragment) + .hide(mineFragment) + .commit(); + } + private void showFragment(Fragment fragment) { + getSupportFragmentManager().beginTransaction() + .show(fragment) + .commit(); + } + + private void setupImageButtons() { 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); - } - }); - + imageButton1.setOnClickListener(v -> selectFragment(imageButton1, homeFragment)); + imageButton2.setOnClickListener(v -> selectFragment(imageButton2, findFragment)); + imageButton3.setOnClickListener(v -> selectFragment(imageButton3, vipFragment)); + imageButton4.setOnClickListener(v -> selectFragment(imageButton4, shoppingTrolleyFragment)); + imageButton5.setOnClickListener(v -> selectFragment(imageButton5, mineFragment)); } -} \ No newline at end of file + + private void selectFragment(ImageButton selectedButton, Fragment fragment) { + hideAllFragments(); + showFragment(fragment); + updateButtonSelection(selectedButton); + } + + private void updateButtonSelection(ImageButton selectedButton) { + ImageButton[] buttons = {findViewById(R.id.imageButton4), findViewById(R.id.imageButton5), + findViewById(R.id.imageButton6), findViewById(R.id.imageButton7), findViewById(R.id.imageButton8)}; + for (ImageButton button : buttons) { + button.setSelected(button == selectedButton); + } + } +} diff --git a/app/src/main/java/com/example/myapplication/zixunkefuActivity.java b/app/src/main/java/com/example/myapplication/zixunkefuActivity.java new file mode 100644 index 0000000..18bc409 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/zixunkefuActivity.java @@ -0,0 +1,29 @@ +package com.example.myapplication; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.view.View; +import android.content.Intent; +import android.widget.ImageButton; + +public class zixunkefuActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_zixunkefu); + + + //返回 + ImageButton imageButton = findViewById(R.id.imageButton20); + imageButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(zixunkefuActivity.this,yindaoActivity.class); + intent.putExtra("fragment","MineFragment"); + startActivity(intent); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/dengjixiangqing.png b/app/src/main/res/drawable/dengjixiangqing.png new file mode 100644 index 0000000..062f0a7 Binary files /dev/null and b/app/src/main/res/drawable/dengjixiangqing.png differ diff --git a/app/src/main/res/drawable/fanhui.png b/app/src/main/res/drawable/fanhui.png new file mode 100644 index 0000000..a67dc8c Binary files /dev/null and b/app/src/main/res/drawable/fanhui.png differ diff --git a/app/src/main/res/drawable/qiehuanzitidian.png b/app/src/main/res/drawable/qiehuanzitidian.png new file mode 100644 index 0000000..b455f6a Binary files /dev/null and b/app/src/main/res/drawable/qiehuanzitidian.png differ diff --git a/app/src/main/res/drawable/shangjiashangpin.png b/app/src/main/res/drawable/shangjiashangpin.png new file mode 100644 index 0000000..c6f174d Binary files /dev/null and b/app/src/main/res/drawable/shangjiashangpin.png differ diff --git a/app/src/main/res/drawable/tuanzhangruzhu.png b/app/src/main/res/drawable/tuanzhangruzhu.png new file mode 100644 index 0000000..3436bf3 Binary files /dev/null and b/app/src/main/res/drawable/tuanzhangruzhu.png differ diff --git a/app/src/main/res/drawable/tuanzhangzhongxin.png b/app/src/main/res/drawable/tuanzhangzhongxin.png new file mode 100644 index 0000000..b42236c Binary files /dev/null and b/app/src/main/res/drawable/tuanzhangzhongxin.png differ diff --git a/app/src/main/res/drawable/tuihuoshouhou.png b/app/src/main/res/drawable/tuihuoshouhou.png new file mode 100644 index 0000000..f0833fc Binary files /dev/null and b/app/src/main/res/drawable/tuihuoshouhou.png differ diff --git a/app/src/main/res/drawable/wodeguanzhu.png b/app/src/main/res/drawable/wodeguanzhu.png new file mode 100644 index 0000000..75f9757 Binary files /dev/null and b/app/src/main/res/drawable/wodeguanzhu.png differ diff --git a/app/src/main/res/drawable/xiaofeijifen.png b/app/src/main/res/drawable/xiaofeijifen.png new file mode 100644 index 0000000..964d00f Binary files /dev/null and b/app/src/main/res/drawable/xiaofeijifen.png differ diff --git a/app/src/main/res/drawable/yaoqinglaxin.png b/app/src/main/res/drawable/yaoqinglaxin.png new file mode 100644 index 0000000..89e8b1a Binary files /dev/null and b/app/src/main/res/drawable/yaoqinglaxin.png differ diff --git a/app/src/main/res/drawable/yitihuo.png b/app/src/main/res/drawable/yitihuo.png new file mode 100644 index 0000000..1ae2149 Binary files /dev/null and b/app/src/main/res/drawable/yitihuo.png differ diff --git a/app/src/main/res/drawable/zixunkefu.png b/app/src/main/res/drawable/zixunkefu.png new file mode 100644 index 0000000..4767814 Binary files /dev/null and b/app/src/main/res/drawable/zixunkefu.png differ diff --git a/app/src/main/res/layout/activity_dengjixiangqing.xml b/app/src/main/res/layout/activity_dengjixiangqing.xml new file mode 100644 index 0000000..5daa8b9 --- /dev/null +++ b/app/src/main/res/layout/activity_dengjixiangqing.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_tuanzhangruzhu.xml b/app/src/main/res/layout/activity_tuanzhangruzhu.xml new file mode 100644 index 0000000..ebd3735 --- /dev/null +++ b/app/src/main/res/layout/activity_tuanzhangruzhu.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + \ 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 7dfccaf..b801bc5 100644 --- a/app/src/main/res/layout/activity_yindao.xml +++ b/app/src/main/res/layout/activity_yindao.xml @@ -7,6 +7,11 @@ tools:context=".yindaoActivity"> + + + + + + + + + + + + + + + + + + + + + +