I have a child fragment inside the parent fragment.
I want to change the text of the TextView
in custom ActionBar from child fragment here is my code and it gives me an error of null object reference
I have created a custom layout for action bar and inflate this layout with action bar.
Now I have four fragments in main activity. In first fragment there are four buttons. when I tap on the first button it opens another fragment.
I want to change the text of the TextView
from child fragment in custom ActionBar which is inflated with the main activity. the fragment name is Qoutes
fragment and I want to change the text of TextView
to Quotes
.
How I can do this:
Solution:
Try like this:
((your_activity) getActivity()).setHomeAsUpEnabled(false);
You need to cast getActivity()
with the name of your Activity.
Ex: ((MainActivity) getActivity()).setDisplayHomeAsUpEnabled(false);
Same way you can change the text as well:
((MainActivity) getActivity()).setActionBarTitle("Your title");
Any issues, Please comment.