无法导入 android.support.design.internal。*
Not able to import android.support.design.internal.*
正在尝试删除底部导航栏上的动画。
我的 Gradle 与库
正确同步
implementation 'com.android.support:design:29.0.0'
我试过检查过去对这类问题的回答,但仍然
import 语句中的设计关键字显示为红色
这是我的帮手class
package com.shubham.exp;
import android.util.Log;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.lang.reflect.Field;
public class helper {
public static void disableShiftMode(BottomNavigationView view) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
//noinspection RestrictedApi
item.setShiftingMode(false);
// set once again checked value, so view will be updated
//noinspection RestrictedApi
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("BNVHelper", "Unable to get shift mode field", e);
} catch (IllegalAccessException e) {
Log.e("BNVHelper", "Unable to change value of shift mode", e);
}
}
}
error: package android.support.design.internal does not exist
支持库29.0.0doesn't exist。删除此行。
//implementation 'com.android.support:design:29.0.0'
您有 2 个选择:
迁移到androidx并使用implementation 'com.google.android.material:material:1.0.0
使用支持库 28.0.0:implementation 'com.android.support:design:28.0.0'
最后删除 内部包的导入(你不需要它们)。
//import android.support.design.internal.BottomNavigationItemView;
//import android.support.design.internal.BottomNavigationMenuView;
有了新的 AndroidX
工件,不再使用支持库。所以你必须将它迁移到 AndroidX
(如果你还没有这样做)并且在上面的代码中,你需要删除包导入,
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
正在尝试删除底部导航栏上的动画。 我的 Gradle 与库
正确同步implementation 'com.android.support:design:29.0.0'
我试过检查过去对这类问题的回答,但仍然 import 语句中的设计关键字显示为红色
这是我的帮手class
package com.shubham.exp;
import android.util.Log;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.lang.reflect.Field;
public class helper {
public static void disableShiftMode(BottomNavigationView view) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
//noinspection RestrictedApi
item.setShiftingMode(false);
// set once again checked value, so view will be updated
//noinspection RestrictedApi
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("BNVHelper", "Unable to get shift mode field", e);
} catch (IllegalAccessException e) {
Log.e("BNVHelper", "Unable to change value of shift mode", e);
}
}
}
error: package android.support.design.internal does not exist
支持库29.0.0doesn't exist。删除此行。
//implementation 'com.android.support:design:29.0.0'
您有 2 个选择:
迁移到androidx并使用
implementation 'com.google.android.material:material:1.0.0
使用支持库 28.0.0:
implementation 'com.android.support:design:28.0.0'
最后删除 内部包的导入(你不需要它们)。
//import android.support.design.internal.BottomNavigationItemView;
//import android.support.design.internal.BottomNavigationMenuView;
有了新的 AndroidX
工件,不再使用支持库。所以你必须将它迁移到 AndroidX
(如果你还没有这样做)并且在上面的代码中,你需要删除包导入,
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;