From 3946c62c2ea916b0f390ea6284cae0d521777b6f Mon Sep 17 00:00:00 2001 From: YGRXZYGR <1513065229@qq.com> Date: Thu, 6 Jun 2024 00:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=EF=BC=881=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c202201020328/CommunityActivity.java | 8 ++- .../hnucm/c202201020328/MessageFragment.java | 64 +++++++++++++++++ .../hnucm/c202201020328/SquareFragment.java | 65 ++++++++++++++++++ src/main/res/drawable/a.png | Bin 0 -> 1686 bytes src/main/res/drawable/b.png | Bin 0 -> 767 bytes src/main/res/drawable/c.png | Bin 0 -> 1737 bytes src/main/res/drawable/d.png | Bin 0 -> 1318 bytes src/main/res/drawable/e.png | Bin 0 -> 1389 bytes src/main/res/layout/activity_community.xml | 58 ++++++++++++++++ src/main/res/layout/fragment_message.xml | 19 +++++ src/main/res/layout/fragment_square.xml | 21 ++++++ src/main/res/values/strings.xml | 2 + 12 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/hnucm/c202201020328/MessageFragment.java create mode 100644 src/main/java/com/hnucm/c202201020328/SquareFragment.java create mode 100644 src/main/res/drawable/a.png create mode 100644 src/main/res/drawable/b.png create mode 100644 src/main/res/drawable/c.png create mode 100644 src/main/res/drawable/d.png create mode 100644 src/main/res/drawable/e.png create mode 100644 src/main/res/layout/fragment_message.xml create mode 100644 src/main/res/layout/fragment_square.xml diff --git a/src/main/java/com/hnucm/c202201020328/CommunityActivity.java b/src/main/java/com/hnucm/c202201020328/CommunityActivity.java index 38e3804..38bdc98 100644 --- a/src/main/java/com/hnucm/c202201020328/CommunityActivity.java +++ b/src/main/java/com/hnucm/c202201020328/CommunityActivity.java @@ -7,12 +7,18 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; +import androidx.fragment.app.Fragment; public class CommunityActivity extends AppCompatActivity { - + SquareFragment squareFragment=new SquareFragment(); + MessageFragment messageFragment=new MessageFragment(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_community); + //布局切换成fragment + getSupportFragmentManager().beginTransaction().add(R.id.layout,squareFragment).commit(); + getSupportFragmentManager().beginTransaction().add(R.id.layout,messageFragment).commit(); + getSupportFragmentManager().beginTransaction().hide(messageFragment).show(squareFragment).commit(); } } \ No newline at end of file diff --git a/src/main/java/com/hnucm/c202201020328/MessageFragment.java b/src/main/java/com/hnucm/c202201020328/MessageFragment.java new file mode 100644 index 0000000..b898c80 --- /dev/null +++ b/src/main/java/com/hnucm/c202201020328/MessageFragment.java @@ -0,0 +1,64 @@ +package com.hnucm.c202201020328; + +import android.os.Bundle; + +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 MessageFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class MessageFragment 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 MessageFragment() { + // 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 MessageFragment. + */ + // TODO: Rename and change types and number of parameters + public static MessageFragment newInstance(String param1, String param2) { + MessageFragment fragment = new MessageFragment(); + 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) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_message, container, false); + } +} \ No newline at end of file diff --git a/src/main/java/com/hnucm/c202201020328/SquareFragment.java b/src/main/java/com/hnucm/c202201020328/SquareFragment.java new file mode 100644 index 0000000..2d8be48 --- /dev/null +++ b/src/main/java/com/hnucm/c202201020328/SquareFragment.java @@ -0,0 +1,65 @@ +package com.hnucm.c202201020328; + +import android.os.Bundle; + +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 SquareFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class SquareFragment 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 SquareFragment() { + // 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 SquareFragment. + */ + // TODO: Rename and change types and number of parameters + public static SquareFragment newInstance(String param1, String param2) { + SquareFragment fragment = new SquareFragment(); + 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) { + // Inflate the layout for this fragment + View view=inflater.inflate(R.layout.fragment_square, container, false); + return view; + } +} \ No newline at end of file diff --git a/src/main/res/drawable/a.png b/src/main/res/drawable/a.png new file mode 100644 index 0000000000000000000000000000000000000000..d65988260290a7f0ac8d47cd7786571d0c117a79 GIT binary patch literal 1686 zcmeAS@N?(olHy`uVBq!ia0y~yU^E1>S8%Wa$&Tuq;XsP9ILO_JVcj{Imp~3nx}&cn z1H;CC?mvmFKt5-IM`SSrgHQJiU0rdo)nJ~ ziJH~H?-D4jxniY@l&i|3E~%rOr3WSi2wAr|9rg}wvi<$&?$?)()-A|YORP^?8Yv}DfDRo(vi{g3Y@?9w=M z@tKF9v_Jo&M{^7JnA&ID*Jqya_4euNk0;j_{wcPI7D?Y3X_a)Ff7!=(Umf2cWSlqM zIDGewJ@%1Pp1=HjrQ@vrzNEkMkAHlfUcHx{rQ%-STKk^Q=58MkSI8|`e&)Pej)7&z zXY0lHni4#LM|#`sWjEdH;C&vR@IIeg z;zHZ@{jZ*dr~K9b@n0ip^G~rai+{##$yaQc{`5^v_RsY{`9A)C?k@QI(YdZ_RKlEo~)nXuv_kK#{c`DEt2~4mR7uvUf;}^YrS`;_;)t{ZBzS| z%U;gQRS7tJ+Ijug}y~_4!lWnz{4d zYyXyGS&{H|>-pdE3@Z}WzMsty+944ztAlZAC+XDrCqJg@-P>tr@#n^Vd%26d`^N@j0Ru`To&kcJ{&z75`>Gx83~Xjo10g<(W!hC&in86m6;4H*@Nl^6S;-tbK(y zdg<{!+SIYOWZS-*Z|%REcpuRc+&Hzrg8x-00?K_2nk02?1->c3hV4xTjR1uPH?r$kuW=@u>Ouvr6g^6!PV~gjM0p(xuiQUH%;~P z+VYJW?nk_C_D-H1JLj(4(boO_kIw5~Y@M6<=ixV#W!>uaRcendc3-XU5r6ee!|ukb zM^}#S`|NkxrDx0J=*bc~QB&r*zkhQJk}N*U{T|eDOMbfCA`JEHMUA?f5YJY>J*Dx_ zY=*13ZO2K+BX2sEeb&E!|J9?b^R^~NDjhSf{QKH*&vx4${(aI%+ueNn{1`ISV`@iy0V%Nm7zv-Pl zZ*zx$f*_NMQ-ce~1P(?aMF%Aoj~0ebgy0!xnSS^GQ{SF(x|6p(&1$aM-njKMebmn8 zZU20K<4jMEb_1#2I)QuXl80rEsI$xrmV9GRu2a5Y# zCqy1>XnWD6u(^Sedts}B^YMn33vLq>lMgs9ahk9&$-!|6ke778;R%qJ=-}`K$V(Jy z*8r+KsKFH|<=EB`$iu|y7$&utgGH)ojfz_tM+i%#X3rXd7aW^}ByK9KQ8-bQoYJ_V zP2qIsM43ZcO*-OkK^(6+HpxhwRLF9iu=JP*Q=oK{j%u5g%UX_2Arh+uwkn?pN?75v zW4|MBY(?(t@4wGJ{`g_}HBa70MLSvacU{Zf9$jBF_lknw^573m*>{sReo(*e$$RMU ze5V&cZjIe{5cg4y9lQRHYq@69K(!(F*RVG`epr-!=kw1mK$AodZH>`u7LPl9>~Uf7 z-nhS+UxV5UcDi?0pP#TcZ1sbM7oOYo?Vta+ZvSuLSJPP@-M{v_^uvM|#R5A|F(v+# zoT%;O5+=(MKkL?GVai{g~;Fb)}&r3T6WR+a1TRM6K zCJHWcZpr8e(m?ek9RhDbw2NB@pWvdsIs(7{+ErZ0pC+7SHv4C^U%Xhy_19lNzu=Pn zw*54#p$y;b!w(M@sFb^Bz6oA9|8LpO(_9Db+;OB1Xp(X9{VX22_}Ug>0Z(;c PqGj-O^>bP0l+XkKk2y6G literal 0 HcmV?d00001 diff --git a/src/main/res/drawable/c.png b/src/main/res/drawable/c.png new file mode 100644 index 0000000000000000000000000000000000000000..759300319b10ce1171bd66675aa55b4067493ac8 GIT binary patch literal 1737 zcmV;)1~&PLP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&23|=-K~#8N?VR09 z6mJyAe}94qQX*byq$m;^p-G`6C@KhQk*OqflVX%$7l!XQii!yqqNI_LB#{|J7$pdi zMkOhc^nzrTk(OwJh25NfXE_Tpb7o(hGc!BxeBgVt&zYU`e0TTR=WU+44yynOi* z=H}*LVPOGQR#sebb|GMmzjyB*l$Di1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%mvv4FO#rG=aFGB2 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable/e.png b/src/main/res/drawable/e.png new file mode 100644 index 0000000000000000000000000000000000000000..6523a69415ff272db879c31ed0c9c5aa4b8c738c GIT binary patch literal 1389 zcmV-z1(N!SP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&1p-M#K~#8N?VQUi zZBZP@@1G!LAj!Zhk%1&BMHwh2o<)=xh*As~DP=;+BP9_7q)0L`@Q8^4kyj#8@+^;u zh%ouxe!HdXp8GpzpU3*`z4pHAQ{Pf&?Q_;|f405P*=w!+3pC20WhjJ}p%7YzLTDKZ zp=Bt9mZ1<@hC*l=3ZZ2vgd=6Vy}iNH(-T}>UBT(;DeUggp=g*VjW>SXjWRs;YvSnHjjdyA$uGCQ8dd0c~we-`__Z6|M@L7{(9l5cEUS{0l?Ai2v!X}#V7rXT$w`Qdiz9cC9qH`s6g{&Z zTV=Ggw2(W*?o?M-iym5wZ8CCmbIBc{N-{DsL{F{578z9Ws>Vtzmw~4Ms%TYHSXd}} z&X1)s#>dCWf>lpfSC^=O7t3TUFE5jYIwhl{qoNW%ERk`1d<-cmDP)mO%KZGisE7wk zWHdE3k;OSJ+1c6f_4OsHk`KF#&CN}+FsEjCcvw^>A9fjab#-J>PEC4xI=sBRi0b6R zDg$r)Q3W|Ycw>$b?14{rx@JdADU^VnS3b2NoGqQ&VK;-Ij`q3Q@5f zSY$Zu&TJ@=35yK8Z9sM0jd^{26;+20i;SeCB(mdf3|=2)!6F0aBvBnVOJ-)KF+pKv zWyKgnpxRKuwzv&`_fJhtCEIwWrltlK78Z=)-&7laa(;d;stz6LGCn^)$xfSv8d1af zvsBxk+27w6t^bgdlS8)s4mDU5i2R?SK0jEb%fOpxRHx0dwY4SQ;cxI83)LRu?c2=2 zzyR4E6B`>VTKx;YMs4FOc)-X)x(xgwM0MIM-tcwAQb#!A>p#lZm^QvfZR0CTOG{$w z(2*|V`T3dbv{|;dx5YdBjj!`LzD6-LG(@(?;DkAE1T&d#eSKYQ9Xirw;7AzNX|v$P z+Y`LFQf+@Gm}>?lG1!YZt_hKabQwr=bTrva-yQ5;Oy*7 zR3{fLBfxZYbco92qh$n;`1p9ZzP=Wf$w$iwAl=>FqADJ=3_sJ@*eELEL(A|ZRxLl) zGE9O~f2=~wFo~6D8D3)5sp%(L1`%&lfVg3o5fc+b7OZNlcoKp)*kw3nJRG0I#{C2Y zGuUO|ydtxCOm^nKd`2P8FT!b;{sfOu?vXCw-% z4F#OjT3cIdOppt7#$s7n8H|mM8IS8$8OO-* + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/res/layout/fragment_message.xml b/src/main/res/layout/fragment_message.xml new file mode 100644 index 0000000..28c5f6a --- /dev/null +++ b/src/main/res/layout/fragment_message.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/res/layout/fragment_square.xml b/src/main/res/layout/fragment_square.xml new file mode 100644 index 0000000..62a8360 --- /dev/null +++ b/src/main/res/layout/fragment_square.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 8cc2182..1506122 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1,3 +1,5 @@ My Project + + Hello blank fragment \ No newline at end of file