Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/04/2016, 14:35
djruiz
 
Fecha de Ingreso: enero-2016
Mensajes: 7
Antigüedad: 8 años, 4 meses
Puntos: 0
Pregunta Lanzar una activity desde un fragment

Hola a todos, tengo un problemilla, quiero abrir o lanza una activity desde un fragment,
esto lo estoy haciendo en android studio

este es el codigo que tengo


Código Java:
Ver original
  1. import android.content.Context;
  2. import android.net.Uri;
  3. import android.os.Bundle;
  4. import android.support.v4.app.Fragment;
  5. import android.view.LayoutInflater;
  6. import android.view.View;
  7. import android.view.ViewGroup;
  8. import android.widget.Button;
  9.  
  10.  
  11. public class Login extends Fragment {
  12.  
  13.     private OnFragmentInteractionListener mListener;
  14.  
  15.     public Login() {
  16.  
  17.     }
  18.  
  19.  
  20.     @Override
  21.     public View onCreateView(LayoutInflater inflater, ViewGroup container,
  22.                              Bundle savedInstanceState) {
  23.         // Inflate the layout for this fragment
  24.  
  25.         return inflater.inflate(R.layout.fragment_login, container, false);
  26.  
  27.     }
  28.  
  29.     // TODO: Rename method, update argument and hook method into UI event
  30.     public void onButtonPressed(Uri uri) {
  31.         if (mListener != null) {
  32.             mListener.onFragmentInteraction(uri);
  33.         }
  34.     }
  35.  
  36.     @Override
  37.     public void onAttach(Context context) {
  38.         super.onAttach(context);
  39.         if (context instanceof OnFragmentInteractionListener) {
  40.             mListener = (OnFragmentInteractionListener) context;
  41.         } else {
  42.             throw new RuntimeException(context.toString()
  43.                     + " must implement OnFragmentInteractionListener");
  44.         }
  45.     }
  46.  
  47.     @Override
  48.     public void onDetach() {
  49.         super.onDetach();
  50.         mListener = null;
  51.     }
  52.  
  53.     public interface OnFragmentInteractionListener {
  54.         // TODO: Update argument type and name
  55.         void onFragmentInteraction(Uri uri);
  56.     }
  57. }