I have a navigation drawer & on click of certain items of navigation drawer, i am opening Fragment.These fragments does not have an activity. I have an edittext in my fragment,on click of it i am setting some view to invisible and on click of back button of keyboard i want to again show the view which were invisible on click of edittext. My fragment does not have an activity so i cant implement onBackPressed. Please help
You can apply a listener in your fragment view doing this:
view.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK){
// handle back button's click listener
return true;
}
return false;
}
});