Parama Sudha
Parama Sudha

Reputation: 2623

Hiding of a ToolBar icon only for a specific Fragment

I am using an Activity which has 3 fragment.Back Arrow is visible because of using the following line. android:parentActivityName=".Activity.MainActivity". But I need to hide this <--(Back Arrow) only for a particular fragment abd it has to be visible in another 2 fragment. What do I need to do?

enter image description here

Upvotes: 2

Views: 1717

Answers (2)

Masum
Masum

Reputation: 4959

Use this line of code in your fragment onCreateView() where you want to remove the back button

getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);

or

((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);

Upvotes: 4

Damini Mehra
Damini Mehra

Reputation: 3347

try this code in your fragment:

    getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);

Upvotes: 2

Related Questions