Rahul Chaudhary
Rahul Chaudhary

Reputation: 1061

Null pointer exception in action bar

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.

Upvotes: 1

Views: 87

Answers (2)

RajSharma
RajSharma

Reputation: 1971

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...

Upvotes: 2

Deepak Purohit
Deepak Purohit

Reputation: 1

Change Activity theme in Android Manifest to Theme.Holo

Upvotes: 0

Related Questions