gpt4 book ai didi

android - 类型参数 T 具有不兼容的上限 : View and BottomNavigationViewEx

转载 作者:行者123 更新时间:2023-11-29 02:23:33 25 4
gpt4 key购买 nike

我曾尝试使缓存无效/重新启动并重命名 xml 文件,但没有成功。当我尝试使用 findViewById 方法设置变量时出现错误。此外,通过在此之前添加隐式 (BottomNaviagtionViewEx),我收到以下错误:Inconvertable types;无法将“android.view.View”转换为“com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx”。

这是我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="layout.index.HomeFeed">

<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/containter"
android:layout_above="@+id/bottomNavLayout">

</android.support.v4.view.ViewPager>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:id="@+id/bottomNavLayout">

<include layout="@layout/layout_bottom_navigation_view">

</include>
</RelativeLayout>

</RelativeLayout>

还有我的 java 文件

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx;

public class test extends AppCompatActivity {

BottomNavigationViewEx bottomBar;
Menu bottomBarMenu;
MenuItem bottomBarMenuItem;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);

bottomBar = (BottomNavigationViewEx) findViewById(R.id.bottomNavBar);
}
}

顶级gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}

allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

应用级gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.test.edward.test"
minSdkVersion 21
targetSdkVersion 27
versionCode 2
versionName "1.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
implementation "com.android.support:design:27.1.1"
}

apply plugin: 'com.google.gms.google-services'

任何帮助将不胜感激,谢谢

编辑:这是我的 layout_bottom_navigation_view.xml 文件

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true">

<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bottomNavViewBar"
android:background="@drawable/border_bottom"
app:menu="@menu/bottom_navigation_menu">

</com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>

</RelativeLayout>

</merge>

但是,即使我将 BottomNavigationViewEx 直接添加到主 Activity 中,错误也没有消除。谢谢

最佳答案

已解决:改变了

compileSdkVersion 27

targetSdkVersion 27

compileSdkVersion 28

targetSdkVersion 28

并从应用级 gradle 中删除了以下行:

implementation "com.android.support:design:27.1.1"
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'

关于android - 类型参数 T 具有不兼容的上限 : View and BottomNavigationViewEx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53620156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com