asked    May     2018-07-25       android       125 view        1 Answer

[SOLVED] Cannot resolve method 'setShiftingMode(Boolean)' in BottomNavigationView

After upgrading to latest support library '28.0.0-alpha1' I cannot disable shifting mode in my BottomNavigationView i.e. the BottomNavigationItemView.setShiftingMode() method is no longer available.

java.lang.NoSuchFieldException: No field mShiftingMode in class Landroid/support/design/internal/BottomNavigationMenuView; 
    W/System.err:     at java.lang.Class.getDeclaredField(Native Method)
    at com.avocure.avocurehealth.utils.ViewUtils.removeNavigationShiftMode(ViewUtils.java:44)
    at com.avocure.avocurehealth.ui.main.MainActivity.init(MainActivity.java:125)
    at com.avocure.avocurehealth.ui.main.MainActivity.onCreate(MainActivity.java:107)
    at android.app.Activity.performCreate(Activity.java:6679)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I use this method to disable shifting mode.

It would be very much appreciated if anyone could shed some light on whether something has changed in the latest version or is this a bug or something.

  1 Answer  

        answered    Jay     2018-07-25      

Found the answer. In support library 28.0.0-alpha1 we can now add labels (remove shifting mode) using any of the following methods:

XML:

<android.support.design.widget.BottomNavigationView
        .
        .
        .
        app:labelVisibilityMode="labeled" />

Code:

mBottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);

Or:

@SuppressLint("RestrictedApi")
public static void removeNavigationShiftMode(BottomNavigationView view) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
    menuView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
    menuView.buildMenuView();
}




Your Answer





 2018-07-25         Lucy

How do i open a sample Android SDK app in Eclipse

I have created a basic program in Eclipse for Android 2.1. then I wanted to look at some of the samples, and import sample projects which are in the SDK directory. I have tried opening a new project and 'create project from existing source', I browse and can select a project, all the details come up and I can click finish, but I receive an error message saying 'could not write file', and if I click on details, it says "access is denied" I have tried copying a project folder into my own workspace but it still does the same thing. Right click in the package explorer window...
 android                     6 answers                     104 view
 2018-07-25         Augus

'required items could not be found' error when installing ADT plugin

Cannot complete the install because one or more required items could not be found. Software being installed: Android Development Tools 12.0.0.v201106281929-138431 (com.android.ide.eclipse.adt.feature.group 12.0.0.v201106281929-138431) Missing requirement: Android Development Tools 12.0.0.v201106281929-138431 (com.android.ide.eclipse.adt.feature.group 12.0.0.v201106281929-138431) requires 'org.eclipse.gef 0.0.0' but it could not be foundSome info:Eclipse SDK Version: 3.6.2jdk-6u26-windows-i586Windows 7Any suggestions on how to solve this 'required items could not be fo...
 android                     2 answers                     4 view
 2018-07-25         Harold

Where can I download an older version of the Android SDK?

I want to download an older version of the Android SDK: 21.0.0, Where can I do this?I currently have the latest version of the android SDK, downloaded from HERE. However I want an older version, can the Full older version of the SDK be downloaded from anywhere?I am trying to get the older version using SDK manager, but It is not working. I.e. it is only giving me build tools etc. Have you tried the links at: http://developer.android.com/sdk/older_releases.html?OR -First check this link to find out what revision number you need. Then use one of these links:http://dl-s...
 android                     3 answers                     6 view