I'm creating a RecyclerView
with a grid layout using GridLayoutManager
. Everything seems fine until i try to set the layout to the RecyclerView. I have used this code/layout files before so i know it works, however after migrating to Androidx
i am suddenly experiencing issues.
Code (in Activity):
RecyclerView recyclerView = findViewById(R.id.rv_checks);
recyclerView.setHasFixedSize(true);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setFocusable(false);
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
recyclerView.setLayoutManager(gridLayoutManager);
RecyclerView:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_checks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/action_container"
android:layout_marginTop="5dp"
android:clipToPadding="false"
android:padding="20dp"/>
build.gradle:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
Error:
error: incompatible types: GridLayoutManager cannot be converted to LayoutManager