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 0000000..d659882
Binary files /dev/null and b/src/main/res/drawable/a.png differ
diff --git a/src/main/res/drawable/b.png b/src/main/res/drawable/b.png
new file mode 100644
index 0000000..e1425c8
Binary files /dev/null and b/src/main/res/drawable/b.png differ
diff --git a/src/main/res/drawable/c.png b/src/main/res/drawable/c.png
new file mode 100644
index 0000000..7593003
Binary files /dev/null and b/src/main/res/drawable/c.png differ
diff --git a/src/main/res/drawable/d.png b/src/main/res/drawable/d.png
new file mode 100644
index 0000000..57421cb
Binary files /dev/null and b/src/main/res/drawable/d.png differ
diff --git a/src/main/res/drawable/e.png b/src/main/res/drawable/e.png
new file mode 100644
index 0000000..6523a69
Binary files /dev/null and b/src/main/res/drawable/e.png differ
diff --git a/src/main/res/layout/activity_community.xml b/src/main/res/layout/activity_community.xml
index 5c6d0ed..e591788 100644
--- a/src/main/res/layout/activity_community.xml
+++ b/src/main/res/layout/activity_community.xml
@@ -5,6 +5,64 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="#FFFFFF"
tools:context=".CommunityActivity">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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