Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actionbar view not found when compiled with 21 version in android studio #1

Open
elluminati10 opened this issue Feb 29, 2016 · 1 comment

Comments

@elluminati10
Copy link

in following function getting null pointer exception in this line.
"actionBarView = (View) home.getParent().getParent().getParent();"

please provide gradle build.

public static View getActionBarView(ViewGroup decor)
throws NoActionBarException {
View actionBarView;
Context context = decor.getContext();

    View home = decor.findViewById(android.R.id.home);
    if (home == null) {
        int homeId = context.getResources().getIdentifier("abs__home",
                "id", context.getPackageName());
        home = decor.findViewById(homeId);
    }

    actionBarView = (View) home.getParent().getParent().getParent();
    if (actionBarView == null) {
        throw new NoActionBarException();
    }

    return actionBarView;
}
@dptks19
Copy link

dptks19 commented Aug 4, 2016

@elluminati10 you need to use ActionbarSherlock to use this feature.

abs_home is part of ActionbarShrelock lib : https://github.com/JakeWharton/ActionBarSherlock/search?utf8=%E2%9C%93&q=abs__home

Add following line to your gradle of DobSliding module - if you are using android studio, else download the lib from officials http://actionbarsherlock.com/download.html

compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

else download the lib from officials http://actionbarsherlock.com/download.html

Some facts about ActionbarSherlock
JakeWharton/ActionBarSherlock#38

The point is while you use TabActivity and child activity inside Tabhost, you will face the same issue once you call ((TabActivity) getParent()).getActionBar().set...() in your childActivity Extends Activity and then try to create object of

    // Initialization
    try {
        // Instance of this activity as a parameter
        vSlidingMenu = new DobSlidingMenu(this);

        // Sliding type can be sizing or moving
        vSlidingMenu.setSlidingType(SlidingType.SIZE);

   ..}

if you just use getActionBar().set...() ... then the null pointer error will lies here for any method call using getActionBar() ... before you can create object of DobSlidingMenu

minSdkVersion >= 19 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants