Questions related to Kotlin Android Extensions
Questions tagged [kotlin-android-extensions]
721 questions
12
votes
1 answer
How to use null with kotlin @Parcelize
Here is very simple code:
@Parcelize
data class Inner(val a: Int): Parcelable
@Parcelize
data class Test(val a: Int, val inner: Inner?): Parcelable
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun testParcel() {
…

vmtrue
- 1,724
- 18
- 36
12
votes
2 answers
Android Studio 3.0 Kotlin changes are not reflected in the build
Has anyone tried the new android studio with 3.0 for kotlin. I am seeing a weird issue where the Kotlin code changes are not reflected when I run the app but the java changes can be seen. When I debug the app, the code won't stop at the new lines of…

abat
- 655
- 1
- 9
- 19
11
votes
4 answers
Jetpack Compose: Custom VectorAsset Icon object similar to built-in `Icons.Default`
It looks like the only way to go about loading custom icons from Android Vector Resources in the res folder is to do it within a @Composable function using the vectorResource(R.drawable.myVectorName) method.
This is great and all, but I like the…

foxtrotuniform6969
- 3,527
- 7
- 28
- 54
11
votes
2 answers
Navigate to a fragment with navArgs using notification
I'm new with working with notifications in my app so please bear with me.
I have a pending intent which will navigate to MainActivity when the user clicks on it. I want to change it so that it navigates to a fragment that has navigation…

Maryam Mirzaie
- 536
- 6
- 24
11
votes
3 answers
How to use Parcel.readTypedList() along with @Parcelize from kotlin-android-extensions?
I'm running into a problem with implementing Parcelable-based state persistence in a View. Namely, as I need to implement the methods of BaseSavedState like this:
class SavedState : BaseSavedState {
lateinit var myList: ArrayList
…

EpicPandaForce
- 79,669
- 27
- 256
- 428
11
votes
1 answer
Parcelize annotation in AIDL: Incompatible types: Object cannot be converted to MyCustomObject
I'm rewriting my model class to Kotlin, which has to be Parcelable and used in AIDL:
@Parcelize
data class MyCustomObject(val value1: String, val value2: String) : Parcelable
During compilation it crashes with error:
error: incompatible types:…

Yurets
- 3,999
- 17
- 54
- 74
11
votes
3 answers
SomeApp "is never used"
Below in the image 1 you can see I created a Kotlin class that extends from the Application() class:
I also added the necessary stuff in my Manifest file as you can see in the next image:
However I can't figure out why Android Studio maintains…

Hoornet
- 1,398
- 3
- 18
- 30
11
votes
0 answers
How to use Kotlin Android Extensions with ViewStub properly?
Does the extensions have a magic to call inflated view? As far as I see, I should break the harmony of code and call findViewById.
The intent was to inflate layout_ongoingView layout at sometime, and make hidden, and visible again based on…

blackkara
- 4,900
- 4
- 28
- 58
11
votes
8 answers
How to create a button in Kotlin that opens a new activity (Android Studio)?
Hello I'm making an app using Android Studio and the Kotlin language and am having trouble getting my button to open a new activity. I have the button created in my xml file but I can't find the KOTLIN syntax of how to declare it in MainActivity.kt…

Nutters
- 797
- 2
- 6
- 12
11
votes
2 answers
Kotlin : Cannot find symbol class Fragment or other android classes
I have a java fragment with viewPager in it..
public class FragmentWithViewPager extends Fragment {
private class ViewPagerAdapter extends FragmentStatePagerAdapter {
ViewPagerAdapter(FragmentManager fm) {
super(fm);
…

erluxman
- 18,155
- 20
- 92
- 126
10
votes
3 answers
How to inflate a ViewStub using ViewBinding in Android
As Kotlin Synthetics is deprecated, we are migrating to ViewBinding.
I have tried a lot of googling and reading documentation on ViewStub, ViewBinding and have implemented ViewBinding for Fragments Activities, include, merge tags however I could not…

Karan Sharma
- 2,353
- 4
- 28
- 46
10
votes
1 answer
Android: error: non-static type variable T cannot be referenced from a static context
I have the following class:
@Parcelize
data class Collection constructor(
var models: List,
var cursor: String?
) : Parcelable
When I was using Kotlin 1.4.10, the project builds correctly without any errors, then I…

Mahmoud Jorban
- 111
- 7
10
votes
2 answers
What's the purpose of combining coroutine contexts in Kotlin?
https://kotlinlang.org/docs/reference/coroutines/coroutine-context-and-dispatchers.html#combining-context-elements
The official document says I can combine some coroutine contexts, but what's the purpose of doing so and what's the effect?
Does that…

goodonion
- 1,401
- 13
- 25
10
votes
4 answers
Create New Instance of Kotlin Object
I have an object QuickSort that I am attempting to create 2 instances of. When I try to create 2 separate instances I can see that it is only using one instance because I have a count in the QuickSort class that is inaccurate. Kotlin does not use…

AdamHurwitz
- 9,758
- 10
- 72
- 134
10
votes
1 answer
Kotlin: Setting a private Boolean in Java class via a Data class in Kotlin. Why am I not able to do this?
I have a Java class of the format:
class JavaClass {
private String name;
private Boolean x;
public String getName() { return name; }
public void setName(String name) { this.name = name }
public Boolean isX() { return x; }
…

NSaran
- 561
- 3
- 19