【发布时间】:2019-06-19 01:14:04
【问题描述】:
我正在制作一个带有实现 com.roughike:bottom-bar:2.3.1 的底部栏,我想在底部栏项目上调用 setOnTabSelectListener,但我无法从 xml 文件中找到带有 R.id 的底部栏项目。我的问题是什么?
我的来自 res/layout/activity_main 的 XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_bar"
>
</FrameLayout>
<com.roughike.bottombar.BottomBar
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_50dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/tab"
>
</com.roughike.bottombar.BottomBar>
</RelativeLayout>
enter code here
我的来自 res/xml/tab 的 XML
<?xml version="1.0" encoding="utf-8"?>
<tabs>
<tab
id="@+id/home_tab"
icon="@drawable/home_btn"
/>
<tab
id="@+id/search_tab"
icon="@drawable/search_btn"
/>
<tab
id="@+id/new_post_tab"
icon="@drawable/new_post_btn"
/>
<tab
id="@+id/profile_tab"
icon="@drawable/profile_btn"
/>
</tabs>
我的课程来自 java/com.ms.ma/MainActivity
> private void init_bottomBar(){
bottomBar = findViewById(R.id.bottom_bar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(int tabId) {
switch (tabId)
{
case R.id.home_tab: <--here i cant find home_tab-->
break;
}
}
});
}
【问题讨论】:
-
更新到 Android Studio 3.3 后我遇到了同样的问题
-
自从将 Android Studio 更新到 3.3 版后,我看到了相同的“无法解析符号”错误,但项目可以编译并运行。由于某种原因,AS 无法解析 xml 文件中的
标记。下面的答案都没有帮助。
标签: java xml android-studio