Advertisement
Guest User

fragment activity

a guest
May 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.18 KB | None | 0 0
  1. package com.example.myApp;
  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.text.TextUtils;
  8. import android.util.Log;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.Button;
  13. import android.widget.EditText;
  14.  
  15.  
  16. /**
  17.  * A simple {@link Fragment} subclass.
  18.  * Activities that contain this fragment must implement the
  19.  * {@link FragmentCalculatorKinematics.OnFragmentInteractionListener} interface
  20.  * to handle interaction events.
  21.  * Use the {@link FragmentCalculatorKinematics#newInstance} factory method to
  22.  * create an instance of this fragment.
  23.  */
  24. public class FragmentCalculatorKinematics extends Fragment {
  25.     // TODO: Rename parameter arguments, choose names that match
  26.     // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  27.     private static final String ARG_PARAM1 = "param1";
  28.     private static final String ARG_PARAM2 = "param2";
  29.  
  30.     // TODO: Rename and change types of parameters
  31.     private String mParam1;
  32.     private String mParam2;
  33.  
  34.     private OnFragmentInteractionListener mListener;
  35.  
  36.     public FragmentCalculatorKinematics() {
  37.         // Required empty public constructor
  38.     }
  39.  
  40.     /**
  41.      * Use this factory method to create a new instance of
  42.      * this fragment using the provided parameters.
  43.      *
  44.      * @param param1 Parameter 1.
  45.      * @param param2 Parameter 2.
  46.      * @return A new instance of fragment FragmentCalculatorKinematics.
  47.      */
  48.  
  49.  
  50.     // TODO: Rename and change types and number of parameters
  51.     public static FragmentCalculatorKinematics newInstance(String param1, String param2) {
  52.         FragmentCalculatorKinematics fragment = new FragmentCalculatorKinematics();
  53.         Bundle args = new Bundle();
  54.         args.putString(ARG_PARAM1, param1);
  55.         args.putString(ARG_PARAM2, param2);
  56.         fragment.setArguments(args);
  57.         return fragment;
  58.     }
  59.  
  60.     @Override
  61.     public void onCreate(Bundle savedInstanceState) {
  62.         super.onCreate(savedInstanceState);
  63.         if (getArguments() != null) {
  64.             mParam1 = getArguments().getString(ARG_PARAM1);
  65.             mParam2 = getArguments().getString(ARG_PARAM2);
  66.         }
  67.  
  68.  
  69.  
  70.     }
  71.  
  72.     @Override
  73.     public View onCreateView(LayoutInflater inflater, ViewGroup container,
  74.                              Bundle savedInstanceState) {
  75.         // Inflate the layout for this fragment
  76.         return inflater.inflate(R.layout.fragment_fragment_calculator_kinematics, container, false);
  77.  
  78.     }
  79.  
  80.     public void Calculate(View v) {
  81.         EditText InitialVelocityInput = getView().findViewById(R.id.initialVelocityInput);
  82.         EditText VelocityInput = getView().findViewById(R.id.velocityInput);
  83.         EditText AccelerationInput = getView().findViewById(R.id.accelerationInput);
  84.         EditText TimeInput = getView().findViewById(R.id.timeInput);
  85.  
  86.         Log.d("bing", "bing");
  87.     }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.     // TODO: Rename method, update argument and hook method into UI event
  95.     public void onButtonPressed(Uri uri) {
  96.         if (mListener != null) {
  97.             mListener.onFragmentInteraction(uri);
  98.         }
  99.     }
  100.  
  101.     @Override
  102.     public void onAttach(Context context) {
  103.         super.onAttach(context);
  104.         if (context instanceof OnFragmentInteractionListener) {
  105.             mListener = (OnFragmentInteractionListener) context;
  106.         }
  107.     }
  108.  
  109.     @Override
  110.     public void onDetach() {
  111.         super.onDetach();
  112.         mListener = null;
  113.     }
  114.  
  115.     /**
  116.      * This interface must be implemented by activities that contain this
  117.      * fragment to allow an interaction in this fragment to be communicated
  118.      * to the activity and potentially other fragments contained in that
  119.      * activity.
  120.      * <p>
  121.      * See the Android Training lesson <a href=
  122.      * "http://developer.android.com/training/basics/fragments/communicating.html"
  123.      * >Communicating with Other Fragments</a> for more information.
  124.      */
  125.     public interface OnFragmentInteractionListener {
  126.         // TODO: Update argument type and name
  127.         void onFragmentInteraction(Uri uri);
  128.     }
  129.  
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement