Te referís a algo así? http://stackoverflow.com/a/27716825
Si no, deberías enviar el código, y explicar mejor cual es la finalidad o funcionalidad a implementar.
Hola, he empezado con adroid estudio, y quería hacer un navigation drawer activity. Ya tengo hecho mi Fragmentos con mi botón, pero no se como coger ese botón del fragmentos y darle la orden de que me pase a una actividad. He buscado por todos lados pero nada me funciona gracias.
--
Para participar es necesario que leas detenidamente las normas del grupo: https://goo.gl/xeTRQm
---
Has recibido este mensaje porque estás suscrito al grupo "desarrolladores-android" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a desarrolladores-a...@googlegroups.com.
Para publicar una entrada en este grupo, envía un correo electrónico a desarrollad...@googlegroups.com.
Visita este grupo en https://groups.google.com/group/desarrolladores-android.
Para ver este debate en la Web, visita https://groups.google.com/d/msgid/desarrolladores-android/036a36f3-5aae-459e-b3b4-ada1fa69a153%40googlegroups.com.
Para obtener más opciones, visita https://groups.google.com/d/optout.
package app.ismael.com.myapplication;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link FragmentCuantoSabes.OnFragmentInteractionListener} interface
* to handle interaction events.
*/
public class FragmentCuantoSabes extends Fragment {
Button btnfr1;
private OnFragmentInteractionListener mListener;
public FragmentCuantoSabes(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_fragment_cuanto_sabes, container, false);
Button btnfr1 = (Button)view.findViewById(R.id.btnfr1);
btnfr1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v){
switch(v.getId()){
case R.id.btnfr1:
Intent intent1 = new Intent(getActivity(), Main1Activity.class);
startActivity(intent1);//Edited here
break;
}
}
});
return view;
}
// 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;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
Que bueno que lo hayas solucionado, estaría mejor si comentas cual era el problema 😉
Saludos
Arreglado, era un problema de otra actividad que estaba mal. De todas formas gracias
--
Para participar es necesario que leas detenidamente las normas del grupo: https://goo.gl/xeTRQm
---
Has recibido este mensaje porque estás suscrito al grupo "desarrolladores-android" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a desarrolladores-a...@googlegroups.com.
Para publicar una entrada en este grupo, envía un correo electrónico a desarrollad...@googlegroups.com.
Visita este grupo en https://groups.google.com/group/desarrolladores-android.
Para ver este debate en la Web, visita https://groups.google.com/d/msgid/desarrolladores-android/fcd753f7-2993-4163-aaa0-dcbb05608762%40googlegroups.com.