Tengo una duda, por ejemplo tengo un menu donde manejo tres fragmentos, en uno de ellos hay un formulario simple (Para ingresar datos), tres EditText y obviamente un boton, pero cuando voy al archivo de tipo fragment logicamente no es la misma estructura que un Activity normal, entonces no sé en que sector del codigo del fragment se coloca. Este es el codigo
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);
}
}
Obviamente no quiero el codigo de como se hace un registro y esas cosas, solo quiero conocer el sector en donde se deben implementar sin pasar a llevar el funcionamiento del fragment (El codigo esta por defecto, no he implementado nada por lo mismo), o todo los metodos se hacen desde el MainActivity donde estan todos los fragments? . Si me ayudan se los agradeceria un monton.