Advertisement
athacks

Untitled

Jan 9th, 2016
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. package com.atomicalsoftwares.drawertesting;
  2.  
  3. import android.content.Context;
  4. import android.net.Uri;
  5. import android.os.Bundle;
  6. import android.support.v4.app.Fragment;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10.  
  11.  
  12. /**
  13. * A simple {@link Fragment} subclass.
  14. * Activities that contain this fragment must implement the
  15. * {@link Fragment_Home.OnFragmentInteractionListener} interface
  16. * to handle interaction events.
  17. * Use the {@link Fragment_Home#newInstance} factory method to
  18. * create an instance of this fragment.
  19. */
  20. public class Fragment_Home extends Fragment {
  21. // TODO: Rename parameter arguments, choose names that match
  22. // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  23. private static final String ARG_PARAM1 = "param1";
  24. private static final String ARG_PARAM2 = "param2";
  25.  
  26. // TODO: Rename and change types of parameters
  27. private String mParam1;
  28. private String mParam2;
  29.  
  30. private OnFragmentInteractionListener mListener;
  31.  
  32. public Fragment_Home() {
  33. // Required empty public constructor
  34. }
  35.  
  36. /**
  37. * Use this factory method to create a new instance of
  38. * this fragment using the provided parameters.
  39. *
  40. * @param param1 Parameter 1.
  41. * @param param2 Parameter 2.
  42. * @return A new instance of fragment Fragment_Home.
  43. */
  44. // TODO: Rename and change types and number of parameters
  45. public static Fragment_Home newInstance(String param1, String param2) {
  46. Fragment_Home fragment = new Fragment_Home();
  47. Bundle args = new Bundle();
  48. args.putString(ARG_PARAM1, param1);
  49. args.putString(ARG_PARAM2, param2);
  50. fragment.setArguments(args);
  51. return fragment;
  52. }
  53.  
  54. @Override
  55. public void onCreate(Bundle savedInstanceState) {
  56. super.onCreate(savedInstanceState);
  57. if (getArguments() != null) {
  58. mParam1 = getArguments().getString(ARG_PARAM1);
  59. mParam2 = getArguments().getString(ARG_PARAM2);
  60. }
  61. }
  62.  
  63. @Override
  64. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  65. Bundle savedInstanceState) {
  66. // Inflate the layout for this fragment
  67. return inflater.inflate(R.layout.fragment_fragment__home, container, false);
  68. }
  69.  
  70. // TODO: Rename method, update argument and hook method into UI event
  71. public void onButtonPressed(String str) {
  72. if (mListener != null) {
  73. mListener.onFragmentInteraction(str);
  74. }
  75. }
  76.  
  77. @Override
  78. public void onAttach(Context context) {
  79. super.onAttach(context);
  80. if (context instanceof OnFragmentInteractionListener) {
  81. mListener = (OnFragmentInteractionListener) context;
  82. } else {
  83. throw new RuntimeException(context.toString()
  84. + " must implement OnFragmentInteractionListener");
  85. }
  86. }
  87.  
  88. @Override
  89. public void onDetach() {
  90. super.onDetach();
  91. mListener = null;
  92. }
  93.  
  94. /**
  95. * This interface must be implemented by activities that contain this
  96. * fragment to allow an interaction in this fragment to be communicated
  97. * to the activity and potentially other fragments contained in that
  98. * activity.
  99. * <p/>
  100. * See the Android Training lesson <a href=
  101. * "http://developer.android.com/training/basics/fragments/communicating.html"
  102. * >Communicating with Other Fragments</a> for more information.
  103. */
  104. public interface OnFragmentInteractionListener {
  105. // TODO: Update argument type and name
  106. void onFragmentInteraction(String uri);
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement