我对Android开发非常陌生,所以我确信我在这里让初学者犯了错误。我试图通过按照此指南在这里实现底部导航栏:https://segunfamisa.com/posts/bottom-navigation-view-android如何在android中实现底部导航栏?
我已经下载了演示项目,它的工作原理。我现在试图复制底部导航的代码,并使其在另一个android studio项目中工作,并得到这个错误。
我觉得这个错误的原因是这块XML在我的主要活动在那里的引用我想有演出bottom_nav_items:
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
design:menu="@menu/bottom_nav_items" />
我觉得这是做与我有的文件夹结构。演示项目与我的项目有不同的文件夹结构。
凡为我创造了这个项目有这个文件夹结构。
我认为问题是,当我在我的项目文件夹不会出现在包文件夹,而在示范项目是这种情况添加文件夹。
编辑---------------
这是我buildgradle(项目Celebreak)文件: 应用插件: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lewisblack.celebreak"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java/com/lewisblack/celebreak/model']
res.srcDirs = ['src/main/res', 'src/main/res/menu']
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
感谢您的回答。试过这个,我得到'包装'android''属性'菜单'找不到资源标识符的错误。在我的模块应用程序构建gradle中,我也有编译语句。在你的'build.gradle'中加入 –
加上'compile'com.android.support:design:25.0.0'' ... – rafsanahmad007
是build.gradle(Project:Project name)文件还是build.gradle(Module:应用程序)文件?如果是文件中的项目文件,我可以添加它吗? –