Questions tagged [kotlin-android-extensions]

Questions related to Kotlin Android Extensions

Kotlin Android Extensions

721 questions
8
votes
1 answer

How to parcelise member variable other than constructor in data class while using @Parcelize

I am using Room and Kotlin data class. Such as, @Entity(tableName = "Person") @Parcelize class Test(@ColumnInfo(name = "name") var name:String) : Parcelable{ @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "ID") var id: Long? =…
sadat
  • 4,004
  • 2
  • 29
  • 49
8
votes
4 answers

Type mismatch: inferred type is FragmentActivity? but Context was expected

i want to insert menu gridview in tablayout with kotlin. i have been searching for many references in google but it wont help, still getting 1 error in adapter = FoodAdapter(this, foodsList). it says "Type missmatch : inferred type as fragmentHome…
8
votes
0 answers

Using @Parcelize gives Attempt to invoke interface method 'int java.util.Collection.size()' on a null object reference at writeToParcel(Client.kt:0)

The Code for my Parcelable Model class is below, @Parcelize data class Client( @SerializedName("id") var id: Int = 0, @SerializedName("accountNo") var accountNo: String? = null, @SerializedName("status") private val…
8
votes
3 answers

Kotlin - chaining of safe call operator. unnecessary operator calls

Take the following example which uses safe call operator (?.): class Sample { class A( val sampleB: B? = B() ) class B( val sampleC: C = C() ) class C( val sampleInt: Int = 1 ) fun…
8
votes
3 answers

Kotlin view variable is unexpectedly null in Activity onCreate method

I have a small Java Android Studio project, and I used the Kotlin converter in Android Studio 3.0 Canary 3 to convert all four source files to Kotlin. I then made some small modifications to get it to compile. I have only one activity with the…
Eugene
  • 3,417
  • 5
  • 25
  • 49
8
votes
3 answers

Referencing views with the same id in different layouts with kotlin android extensions

In my Android project I have two layouts: num_info and num_info_pack. Both have views with id "circle". So I thought referencing those views by layout_name.circle would solve the problem: val inetView =…
Nazerke
  • 2,098
  • 7
  • 37
  • 57
8
votes
1 answer

"projections are not allowed for immediate arguments of a supertype" Kotlin Android Studio

I am getting this error when I converted Java to Kotlin: Java public class HeaderTab extends ExpandableGroup { private String header; public HeaderTab(String title, List items) { super(title, items); } } Kotlin class…
8
votes
2 answers

Kotlin - List within a List filtering

I have those data classes: data class RouteType( @SerializedName("type") val type: String, @SerializedName("items") val items: List) data class RouteItem( …
Michael
  • 187
  • 1
  • 2
  • 7
7
votes
1 answer

Android Studio 4.1 Canary 6 issue with kapt plugin (e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState)

I use Android Studio 4.1 Canary 6 version and I'm try to use apply plugin: 'kotlin-kapt' plugin then I got this error during build project. e: java.lang.NoSuchMethodError:…
code4rox
  • 941
  • 9
  • 34
7
votes
2 answers

How can I parse Nested JSON with dynamic keys in Android kotlin, Moshi and Retrofit?

How can I parse Nested JSON with NESTED dynamic keys in Android kotlin, Moshi and Retrofit? I get this JSON from alpha-vantage. Format example: { "Meta Data": { "1. Information": "Intraday (15min) open, high, low, close prices and…
Maor Hadad
  • 1,850
  • 21
  • 36
7
votes
1 answer

Dark theme configuration change in Android Q

I want to implement android 10 dark theme in my app , I have these following cases: SYSTEM_DEFAULT, NIGHT_MODE, LIGHT_MODE The problem is when I change theme from night or light to system_default from inside the app and it can not understand whether…
7
votes
1 answer

Unresolved reference when importing views from a submodule using kotlin-android-extensions

When I try to use kotlin-android-extendions' view injection in a multi-module application I get an error injecting a view from an android.library submodule: Unresolved reference: component_xyz_user_name We have a main app module and an…
7
votes
2 answers

I try to implement a Room Database with Androidx, I am getting error

java.lang.RuntimeException: cannot find implementation for com.qbitstream.salesmanagementsystem.data.AppDatabase. AppDatabase_Impl does not exist at androidx.room.Room.getGeneratedImplementation(Room.java:94) I have add every thing…
Sabinmon ks
  • 635
  • 1
  • 7
  • 20
7
votes
4 answers

Kotlin views with synthetic binding and nullability

I've noticed that when using Kotlin's synthetic binding, the view returned is non null (Kotlin will return View!). But this doesn't make much sense to me, since findCachedViewById can actually return null results, meaning that views can actually be…
Guy
  • 6,414
  • 19
  • 66
  • 136
7
votes
1 answer

How to access a view from layout specified in headerLayout of NavigationView using Kotlin in Android

I want to access a TextView which is included inside headerLayout of NavigationView. Is it possible to access the view using Kotlin android extension? I did using this method, but the TextView (here txtName) is always null. Here is my…