Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android back navigation

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
  int itemId = item.getItemId();
  if (itemId == android.R.id.home) {
    // force up navigation to have the same behavior as temporal navigation
    onBackPressed();
    return true;
  } else {
    return super.onOptionsItemSelected(item);
  }
}
Comment

android back navigation


public class MyFragment extends Fragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // This callback will only be called when MyFragment is at least Started.
        OnBackPressedCallback callback = new OnBackPressedCallback(true /* enabled by default */) {
            @Override
            public void handleOnBackPressed() {
                // Handle the back button event
            }
        };
        requireActivity().getOnBackPressedDispatcher().addCallback(this, callback);

        // The callback can be enabled or disabled here or in handleOnBackPressed()
    }
    ...
}

Comment

PREVIOUS NEXT
Code Example
Java :: java bubble sort 
Java :: java jackson cast to list 
Java :: jaxb exclude field 
Java :: install java with brew 
Java :: processing draw circle 
Java :: random processing 
Java :: remove autofocus edittext android 
Java :: how can i to do java home 
Java :: java split first occurrence 
Java :: joptionpane.showmessagedialog 
Java :: java how to open a link 
Java :: convert object to map scala 
Java :: java getdeclaredfield private field 
Java :: string array to stream 
Java :: zpool 
Java :: execute application jar 
Java :: hql return new object from query 
Java :: java get domain from url 
Java :: method to check parameters in java 
Java :: processing load font from file 
Java :: java key pressed 
Java :: java swing jtable different color each row 
Java :: immagini java 
Java :: java test file exist 
Java :: array ausgeben java 
Java :: java string multiply 
Java :: Which of the following is the only Java package that is imported by default? 
Java :: use view binding in fragment 
Java :: jackson create object node from string 
Java :: how to declare list of object in java as constant 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =