I have started working in fragment. I am trying to hide titleBar
in fragment, but i have this Log-cat Error
android fragment requestfeature must be called before adding content
this is a source
public class SendItemsFragment extends Fragment {
Button b1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE);
View rootView = inflater.inflate(R.layout.send_items, container, false);
return rootView;
}
}
This is what worked for me:
Hide action bar
((AppCompatActivity) getActivity()).getSupportActionBar().hide();
You cannot call this method after setting contentView in Activity (LogCat answers your question already). You can do nothing about that. You must change your Fragment to Activity, or design your application in a different way. Eventually you can only hide title from Actionbar
getActivity().getActionBar().hide()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With