Try something else, answer's @vdisawar gives me the idea:
in your Fragment:
// in your onClick method
// call a method in your Activity
((PlanMeMainActivity) getActivity()).newActivityToLaunch();
in your FragmentActivity:
// newActivityToLaunch method
public void newActivityToLaunch() {
Intent myIntent = new Intent(PlanMeMainActivity.this, NewEventSetupActivity.class);
startActivity(myIntent);
}
With this tip, you will able to call different activities with the same method from different fragment, let see a simple example:
FragmentA wants to launch Activity1:
// call a method with an integer
((MainActivity) getActivity()).newActivityToLaunch(1);
in another fragment (FragmentB), this one wants to launch Activity2:
// call the same method with another integer
((MainActivity) getActivity()).newActivityToLaunch(2);
then in your FragmentActivity, the method is:
// newActivityToLaunch method
public void newActivityToLaunch(int i) {
// create a general intent
Intent myIntent = null;
// switch i received from fragments
switch(i) {
// received from FragmentA
case 1: myIntent = new Intent(MainActivity.this, Activity1.class);
// received from FragmentB
case 2: myIntent = new Intent(MainActivity.this, Activity2.class);
}
// start the activity
startActivity(myIntent);
}
Hope this helps.