1

good morning every one,

I am using swipe tabs in fragments but getting null action bar.

Code snippet is given below:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater
                .inflate(R.layout.ride_detail, container, false);
        li = getLayoutInflater(savedInstanceState);
        context = getActivity();
        customizedToast = new CustomizedToast(context, li);
         actionBar = ((ActionBarActivity)getActivity()).getActionBar();

I have also tried with:

 actionBar = getActivity().getActionBar();

Thanks.

3
  • try it, actionBar = getActionBar(); Commented Jun 25, 2015 at 7:23
  • @Soham he should use an AppCompatActivity (not an Activity) Commented Sep 8, 2015 at 7:12
  • getSupportActionBar() Commented Sep 8, 2015 at 7:15

2 Answers 2

2

You should use getSupportActionBar instead of getActionBar if you are working with ActionBarActivity. The getActionBar method is available in the ActionBarActivity API since it extends Activity, but should not be used when working with support Activities.

Check you import which action bar you are importing...

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for providing help
Use AppCompatActivity instead of ActionBarActivity. It is deprecated
0

Change Activity theme in Android Manifest to Theme.Holo

2 Comments

Why should he use a Holo theme in 2015?
You can use Themes like Holo which support Actionbar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.