Guest User

Untitled

a guest
Oct 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. package edu.temple.paletteactivity3;
  2.  
  3.  
  4. import android.os.Bundle;
  5. import android.app.Fragment;
  6. import android.view.LayoutInflater;
  7. import android.view.View;
  8. import android.view.ViewGroup;
  9.  
  10.  
  11. /**
  12. * A simple {@link Fragment} subclass.
  13. * Use the {@link CanvasFragment#newInstance} factory method to
  14. * create an instance of this fragment.
  15. */
  16. public class CanvasFragment extends Fragment {
  17. // TODO: Rename parameter arguments, choose names that match
  18. // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  19. private static final String ARG_PARAM1 = "color";
  20.  
  21. // TODO: Rename and change types of parameters
  22. private int mParam1;
  23.  
  24.  
  25. public CanvasFragment() {
  26. // Required empty public constructor
  27. }
  28.  
  29. /**
  30. * Use this factory method to create a new instance of
  31. * this fragment using the provided parameters.
  32. *
  33. * @param param1 Parameter 1.
  34. * @return A new instance of fragment CanvasFragment.
  35. */
  36. // TODO: Rename and change types and number of parameters
  37. public static CanvasFragment newInstance(int param1) {
  38. CanvasFragment fragment = new CanvasFragment();
  39. Bundle args = new Bundle();
  40. args.putInt(ARG_PARAM1, param1);
  41. fragment.setArguments(args);
  42. return fragment;
  43. }
  44.  
  45. @Override
  46. public void onCreate(Bundle savedInstanceState) {
  47. super.onCreate(savedInstanceState);
  48. if (getArguments() != null) {
  49. mParam1 = getArguments().getInt(ARG_PARAM1);
  50. }
  51. }
  52.  
  53. @Override
  54. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  55. Bundle savedInstanceState) {
  56. // Inflate the layout for this fragment
  57. View v = inflater.inflate(R.layout.fragment_canvas, container, false);
  58. v.setBackgroundColor(mParam1);
  59. return v;
  60. }
  61.  
  62. }
Add Comment
Please, Sign In to add comment