I have a doubt, for example I have a menu where I manage three fragments, in one of them there is a simple form (To enter data), three EditText and obviously a button, but when I go to the fragment type file it is not logically Same structure as a normal Activity, so I do not know in which sector of the fragment code is placed. This is the code
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public fr1perfil() {
// Required empty public constructor
}
public static fr1perfil newInstance(String param1, String param2) {
fr1perfil fragment = new fr1perfil();
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_fr1perfil, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
Obviously I do not want the code of how to make a record and those things, I just want to know the sector where they should be implemented without moving to the operation of the fragment (The code is by default, I have not implemented anything for the same ), or all the methods are done from the MainActivity where all the fragments are? . If they help me, I would appreciate a lot.