【发布时间】:2017-04-05 11:30:29
【问题描述】:
我对 Android 开发非常陌生,所以我确定我在这里犯了初学者的错误。我正在尝试按照此处的指南来实现底部导航栏:https://segunfamisa.com/posts/bottom-navigation-view-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 (Project 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 xml android-layout android-fragments