How to disable/(Hide) autogenerated back arrow in fragment?

Viewed 55

Following is my code snippet, which I am trying.
Error is populated like this way:

enter image description here

Tried to work like this but it couldnot work::
((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);

        return inflater.inflate(R.layout.fragment_itinerary_list, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
    
    }
1 Answers

It sounds like you have a styling issue. In your styles.xml you are going to need to change your theme.

Something like this:

<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

Automatically creates an action bar for you, if you don't want this type of behavoir, but would rather implement it yourself, you should change it to NoActionBar:

<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
Related