我想访问一个变量 initialization
从本地导航的newbottomnav,但我不知道如何访问它?
newbottomnav类:
public final class newBottomNav extends BottomNavigationView {
private final Context context;
private Typeface fontFace = null;
public static Integer initialization = 0;
...
}
本地导航类:
public class LocalNav extends AppCompatActivity {
Context mContext;
WebView view;
BottomNavigationView bottomNavigation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int size = bottomNavigation.getMenu().size();
bottomNavigation.setOnNavigationItemSelectedListener (new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem Item) {
bottomNavigation.initialization = 1; //<= How to access to initialization
...
}
xml格式:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LocalNav">
<WebView
android:id="@+id/vieweb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="0dp"
android:layout_marginBottom="-2dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.NewTelApps.ToEvent.newBottomNav
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
app:itemIconSize="45dp"
android:visible="false"
app:itemBackground="@drawable/nav_item_drawable"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
我不知道如何访问它,因为它是一个底部导航视图。有什么具体的事情要做吗?
提前谢谢。
1条答案
按热度按时间piah890a1#
你只需要把申报单改成
到
作为
initialization
中未定义BottomNavigationView