Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

override onbackpressed in fragment

@Override
public void onResume() {
    super.onResume();

    getView().setFocusableInTouchMode(true);
    getView().requestFocus();
    getView().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
                Toast.makeText(getActivity(), "Back press", Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });

}
Comment

PREVIOUS NEXT
Code Example
Java :: String remove duplicate method in java 
Java :: arraylist add new element to end 
Java :: what is packages in java 
Java :: java url 
Java :: how to check palindrome in java 
Java :: java exception 
Java :: declaration of list in java 
Java :: enum java 
Java :: how to loop through arraylist of objects in java 
Java :: hexstring to string In java 
Java :: HUFFMAN CODING IN JAVA 
Java :: how to get 2 decimal places in java 
Java :: cast java 
Java :: kubectl config kubernetes dashboard 
Java :: add element in the last in double linked list in java 
Java :: maven set java version 
Java :: declaration and definition of array in java 
Java :: chenge font android studio 
Java :: spring boot onetomany relationsion 
Java :: design custom button in android 
Java :: java mcq 
Java :: java sort arraylist of arraylist 
Java :: java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead 
Java :: where is java in ubuntu 
Java :: JFrame frame = new JFrame (); 
Java :: java create xml 
Java :: Employee Java. 
Java :: java 8 stream option 
Java :: how to get index of arraylist in java 
Java :: android navigation drawer open activity 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =