i am trying to handle the onBackPressed diferently for every fragment. for this i want to use a switch statement with cases dependedn on the fragment that is currently showing. in my Main i have. but dont know what to use in the switchstatement.
public class MyActivity extends Activity
{
@Override
public void onBackPressed(){
super.onBackPressed();
switch(........){
case (1):
Fragment1.onBackPressed();
case (2):
Fragment2.onBackPressed();
}
}
in my fragments:
public class Fragment1 extends Fragment
{
//My created method
public static void onBackPressed()
{
// make it do what you want.
}
}
so my question, how can i use a switchstament where de cases are depended on what fragment is showing at this moment.