1
I need from the click of a button inside my Fragment, it call an Activity. My code is like this:
public class ActFoto2 extends Fragment implements View.OnClickListener,
ViewTreeObserver.OnGlobalLayoutListener {
private Button proximo;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
String caminhoFoto = Util.getUltimaMidia(getActivity(), Util.MIDIA_FOTO);
if (caminhoFoto != null) {
mCaminhoFoto = new File(caminhoFoto);
}
proximo = (Button)getActivity().findViewById(R.id.btnProximo);
proximo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), ActMapa.class);
startActivity(intent);
}
});
}
}
But still it does not call, and when I go to test, it for the application. Can someone please assist me. Thanks.
Welcome to Sopt. Add the full stack of errors to the question. this makes it easy to help!
– Thiago Luiz Domacoski
You added the screen in your
AndroidManifest.xml
?– rsicarelli
If
proximo
is a button of Activity declare thesetOnClickListener()
there, if it is not the code is wrong. Post the log of errors.– ramaral