I have a SearchActivity
that works, but I want to be able to close it by pressing back. If I do that right now, first the keyboard is gone (which is as I want), but if I press it again I destroy the fragment. Instead, I want to close the search. Because I am in a fragment I can't manage to make a onBackPressed()
.
Current code:
@Override
public void onBackPressed() {
// Only close if the Fragment reference is null.
if(Ships == null)
{
super.onBackPressed();
}
else
{
Ships.onBackPressed();
}
}