Commit 6d719af49aebe0f550e909e272069ae1f3bd30c4

Authored by 陶汉栋
1 parent b48d20df

no message

app/src/main/java/com/shunzhi/parent/ui/MainActivity.java
@@ -33,7 +33,7 @@ public class MainActivity extends BaseCompatActivity { @@ -33,7 +33,7 @@ public class MainActivity extends BaseCompatActivity {
33 33
34 private int CEPING_INDEX = 0, CONSULT_INDEX = 1, REPORT_INDEX = 2, MINE_INDEX = 3; 34 private int CEPING_INDEX = 0, CONSULT_INDEX = 1, REPORT_INDEX = 2, MINE_INDEX = 3;
35 35
36 - 36 + FragmentTransaction fragmentTransaction=null;
37 @Override 37 @Override
38 protected void initView(Bundle savedInstanceState) { 38 protected void initView(Bundle savedInstanceState) {
39 39
@@ -59,7 +59,7 @@ public class MainActivity extends BaseCompatActivity { @@ -59,7 +59,7 @@ public class MainActivity extends BaseCompatActivity {
59 showFragment(MINE_INDEX); 59 showFragment(MINE_INDEX);
60 break; 60 break;
61 } 61 }
62 - return false; 62 + return true;
63 } 63 }
64 }); 64 });
65 65
@@ -76,6 +76,17 @@ public class MainActivity extends BaseCompatActivity { @@ -76,6 +76,17 @@ public class MainActivity extends BaseCompatActivity {
76 fragments[CONSULT_INDEX] = consultFragment; 76 fragments[CONSULT_INDEX] = consultFragment;
77 fragments[REPORT_INDEX] = reportFragment; 77 fragments[REPORT_INDEX] = reportFragment;
78 fragments[MINE_INDEX] = mineFragment; 78 fragments[MINE_INDEX] = mineFragment;
  79 +
  80 + fragmentTransaction=getSupportFragmentManager().beginTransaction();
  81 + fragmentTransaction.add(R.id.frame,cePingFragment)
  82 + .add(R.id.frame,consultFragment)
  83 + .add(R.id.frame,reportFragment)
  84 + .add(R.id.frame,mineFragment)
  85 + .show(cePingFragment)
  86 + .hide(consultFragment)
  87 + .hide(reportFragment)
  88 + .hide(mineFragment)
  89 + .commit();
79 } 90 }
80 91
81 private void showFragment(int index) { 92 private void showFragment(int index) {
app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java
@@ -10,56 +10,7 @@ import android.view.ViewGroup; @@ -10,56 +10,7 @@ import android.view.ViewGroup;
10 10
11 import com.shunzhi.parent.R; 11 import com.shunzhi.parent.R;
12 12
13 -/**  
14 - * A simple {@link Fragment} subclass.  
15 - * Activities that contain this fragment must implement the  
16 - * {@link OnFragmentInteractionListener} interface  
17 - * to handle interaction events.  
18 - * Use the {@link ConsultFragment#newInstance} factory method to  
19 - * create an instance of this fragment.  
20 - */  
21 public class ConsultFragment extends Fragment { 13 public class ConsultFragment extends Fragment {
22 - // TODO: Rename parameter arguments, choose names that match  
23 - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER  
24 - private static final String ARG_PARAM1 = "param1";  
25 - private static final String ARG_PARAM2 = "param2";  
26 -  
27 - // TODO: Rename and change types of parameters  
28 - private String mParam1;  
29 - private String mParam2;  
30 -  
31 - private OnFragmentInteractionListener mListener;  
32 -  
33 - public ConsultFragment() {  
34 - // Required empty public constructor  
35 - }  
36 -  
37 - /**  
38 - * Use this factory method to create a new instance of  
39 - * this fragment using the provided parameters.  
40 - *  
41 - * @param param1 Parameter 1.  
42 - * @param param2 Parameter 2.  
43 - * @return A new instance of fragment ConsultFragment.  
44 - */  
45 - // TODO: Rename and change types and number of parameters  
46 - public static ConsultFragment newInstance(String param1, String param2) {  
47 - ConsultFragment fragment = new ConsultFragment();  
48 - Bundle args = new Bundle();  
49 - args.putString(ARG_PARAM1, param1);  
50 - args.putString(ARG_PARAM2, param2);  
51 - fragment.setArguments(args);  
52 - return fragment;  
53 - }  
54 -  
55 - @Override  
56 - public void onCreate(Bundle savedInstanceState) {  
57 - super.onCreate(savedInstanceState);  
58 - if (getArguments() != null) {  
59 - mParam1 = getArguments().getString(ARG_PARAM1);  
60 - mParam2 = getArguments().getString(ARG_PARAM2);  
61 - }  
62 - }  
63 14
64 @Override 15 @Override
65 public View onCreateView(LayoutInflater inflater, ViewGroup container, 16 public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -68,42 +19,4 @@ public class ConsultFragment extends Fragment { @@ -68,42 +19,4 @@ public class ConsultFragment extends Fragment {
68 return inflater.inflate(R.layout.fragment_zi_xun, container, false); 19 return inflater.inflate(R.layout.fragment_zi_xun, container, false);
69 } 20 }
70 21
71 - // TODO: Rename method, update argument and hook method into UI event  
72 - public void onButtonPressed(Uri uri) {  
73 - if (mListener != null) {  
74 - mListener.onFragmentInteraction(uri);  
75 - }  
76 - }  
77 -  
78 - @Override  
79 - public void onAttach(Context context) {  
80 - super.onAttach(context);  
81 - if (context instanceof OnFragmentInteractionListener) {  
82 - mListener = (OnFragmentInteractionListener) context;  
83 - } else {  
84 - throw new RuntimeException(context.toString()  
85 - + " must implement OnFragmentInteractionListener");  
86 - }  
87 - }  
88 -  
89 - @Override  
90 - public void onDetach() {  
91 - super.onDetach();  
92 - mListener = null;  
93 - }  
94 -  
95 - /**  
96 - * This interface must be implemented by activities that contain this  
97 - * fragment to allow an interaction in this fragment to be communicated  
98 - * to the activity and potentially other fragments contained in that  
99 - * activity.  
100 - * <p>  
101 - * See the Android Training lesson <a href=  
102 - * "http://developer.android.com/training/basics/fragments/communicating.html"  
103 - * >Communicating with Other Fragments</a> for more information.  
104 - */  
105 - public interface OnFragmentInteractionListener {  
106 - // TODO: Update argument type and name  
107 - void onFragmentInteraction(Uri uri);  
108 - }  
109 } 22 }
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
@@ -10,56 +10,7 @@ import android.view.ViewGroup; @@ -10,56 +10,7 @@ import android.view.ViewGroup;
10 10
11 import com.shunzhi.parent.R; 11 import com.shunzhi.parent.R;
12 12
13 -/**  
14 - * A simple {@link Fragment} subclass.  
15 - * Activities that contain this fragment must implement the  
16 - * {@link OnFragmentInteractionListener} interface  
17 - * to handle interaction events.  
18 - * Use the {@link MineFragment#newInstance} factory method to  
19 - * create an instance of this fragment.  
20 - */  
21 public class MineFragment extends Fragment { 13 public class MineFragment extends Fragment {
22 - // TODO: Rename parameter arguments, choose names that match  
23 - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER  
24 - private static final String ARG_PARAM1 = "param1";  
25 - private static final String ARG_PARAM2 = "param2";  
26 -  
27 - // TODO: Rename and change types of parameters  
28 - private String mParam1;  
29 - private String mParam2;  
30 -  
31 - private OnFragmentInteractionListener mListener;  
32 -  
33 - public MineFragment() {  
34 - // Required empty public constructor  
35 - }  
36 -  
37 - /**  
38 - * Use this factory method to create a new instance of  
39 - * this fragment using the provided parameters.  
40 - *  
41 - * @param param1 Parameter 1.  
42 - * @param param2 Parameter 2.  
43 - * @return A new instance of fragment MineFragment.  
44 - */  
45 - // TODO: Rename and change types and number of parameters  
46 - public static MineFragment newInstance(String param1, String param2) {  
47 - MineFragment fragment = new MineFragment();  
48 - Bundle args = new Bundle();  
49 - args.putString(ARG_PARAM1, param1);  
50 - args.putString(ARG_PARAM2, param2);  
51 - fragment.setArguments(args);  
52 - return fragment;  
53 - }  
54 -  
55 - @Override  
56 - public void onCreate(Bundle savedInstanceState) {  
57 - super.onCreate(savedInstanceState);  
58 - if (getArguments() != null) {  
59 - mParam1 = getArguments().getString(ARG_PARAM1);  
60 - mParam2 = getArguments().getString(ARG_PARAM2);  
61 - }  
62 - }  
63 14
64 @Override 15 @Override
65 public View onCreateView(LayoutInflater inflater, ViewGroup container, 16 public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -68,42 +19,4 @@ public class MineFragment extends Fragment { @@ -68,42 +19,4 @@ public class MineFragment extends Fragment {
68 return inflater.inflate(R.layout.fragment_mine, container, false); 19 return inflater.inflate(R.layout.fragment_mine, container, false);
69 } 20 }
70 21
71 - // TODO: Rename method, update argument and hook method into UI event  
72 - public void onButtonPressed(Uri uri) {  
73 - if (mListener != null) {  
74 - mListener.onFragmentInteraction(uri);  
75 - }  
76 - }  
77 -  
78 - @Override  
79 - public void onAttach(Context context) {  
80 - super.onAttach(context);  
81 - if (context instanceof OnFragmentInteractionListener) {  
82 - mListener = (OnFragmentInteractionListener) context;  
83 - } else {  
84 - throw new RuntimeException(context.toString()  
85 - + " must implement OnFragmentInteractionListener");  
86 - }  
87 - }  
88 -  
89 - @Override  
90 - public void onDetach() {  
91 - super.onDetach();  
92 - mListener = null;  
93 - }  
94 -  
95 - /**  
96 - * This interface must be implemented by activities that contain this  
97 - * fragment to allow an interaction in this fragment to be communicated  
98 - * to the activity and potentially other fragments contained in that  
99 - * activity.  
100 - * <p>  
101 - * See the Android Training lesson <a href=  
102 - * "http://developer.android.com/training/basics/fragments/communicating.html"  
103 - * >Communicating with Other Fragments</a> for more information.  
104 - */  
105 - public interface OnFragmentInteractionListener {  
106 - // TODO: Update argument type and name  
107 - void onFragmentInteraction(Uri uri);  
108 - }  
109 } 22 }
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
@@ -10,56 +10,7 @@ import android.view.ViewGroup; @@ -10,56 +10,7 @@ import android.view.ViewGroup;
10 10
11 import com.shunzhi.parent.R; 11 import com.shunzhi.parent.R;
12 12
13 -/**  
14 - * A simple {@link Fragment} subclass.  
15 - * Activities that contain this fragment must implement the  
16 - * {@link OnFragmentInteractionListener} interface  
17 - * to handle interaction events.  
18 - * Use the {@link ReportFragment#newInstance} factory method to  
19 - * create an instance of this fragment.  
20 - */  
21 public class ReportFragment extends Fragment { 13 public class ReportFragment extends Fragment {
22 - // TODO: Rename parameter arguments, choose names that match  
23 - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER  
24 - private static final String ARG_PARAM1 = "param1";  
25 - private static final String ARG_PARAM2 = "param2";  
26 -  
27 - // TODO: Rename and change types of parameters  
28 - private String mParam1;  
29 - private String mParam2;  
30 -  
31 - private OnFragmentInteractionListener mListener;  
32 -  
33 - public ReportFragment() {  
34 - // Required empty public constructor  
35 - }  
36 -  
37 - /**  
38 - * Use this factory method to create a new instance of  
39 - * this fragment using the provided parameters.  
40 - *  
41 - * @param param1 Parameter 1.  
42 - * @param param2 Parameter 2.  
43 - * @return A new instance of fragment ReportFragment.  
44 - */  
45 - // TODO: Rename and change types and number of parameters  
46 - public static ReportFragment newInstance(String param1, String param2) {  
47 - ReportFragment fragment = new ReportFragment();  
48 - Bundle args = new Bundle();  
49 - args.putString(ARG_PARAM1, param1);  
50 - args.putString(ARG_PARAM2, param2);  
51 - fragment.setArguments(args);  
52 - return fragment;  
53 - }  
54 -  
55 - @Override  
56 - public void onCreate(Bundle savedInstanceState) {  
57 - super.onCreate(savedInstanceState);  
58 - if (getArguments() != null) {  
59 - mParam1 = getArguments().getString(ARG_PARAM1);  
60 - mParam2 = getArguments().getString(ARG_PARAM2);  
61 - }  
62 - }  
63 14
64 @Override 15 @Override
65 public View onCreateView(LayoutInflater inflater, ViewGroup container, 16 public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -68,42 +19,5 @@ public class ReportFragment extends Fragment { @@ -68,42 +19,5 @@ public class ReportFragment extends Fragment {
68 return inflater.inflate(R.layout.fragment_report, container, false); 19 return inflater.inflate(R.layout.fragment_report, container, false);
69 } 20 }
70 21
71 - // TODO: Rename method, update argument and hook method into UI event  
72 - public void onButtonPressed(Uri uri) {  
73 - if (mListener != null) {  
74 - mListener.onFragmentInteraction(uri);  
75 - }  
76 - }  
77 -  
78 - @Override  
79 - public void onAttach(Context context) {  
80 - super.onAttach(context);  
81 - if (context instanceof OnFragmentInteractionListener) {  
82 - mListener = (OnFragmentInteractionListener) context;  
83 - } else {  
84 - throw new RuntimeException(context.toString()  
85 - + " must implement OnFragmentInteractionListener");  
86 - }  
87 - }  
88 22
89 - @Override  
90 - public void onDetach() {  
91 - super.onDetach();  
92 - mListener = null;  
93 - }  
94 -  
95 - /**  
96 - * This interface must be implemented by activities that contain this  
97 - * fragment to allow an interaction in this fragment to be communicated  
98 - * to the activity and potentially other fragments contained in that  
99 - * activity.  
100 - * <p>  
101 - * See the Android Training lesson <a href=  
102 - * "http://developer.android.com/training/basics/fragments/communicating.html"  
103 - * >Communicating with Other Fragments</a> for more information.  
104 - */  
105 - public interface OnFragmentInteractionListener {  
106 - // TODO: Update argument type and name  
107 - void onFragmentInteraction(Uri uri);  
108 - }  
109 } 23 }