How to get value from TypedArray without passing default value

32
October 09, 2019, at 3:30 PM

I'm using the below code to retrieve values from TypedArray in a custom view, but there is something I don't get. If I'm passing default style as 4th parameter then why I have to use getXXXX(R.stylable.res_id, defValue), I mean, what is the point of 4th value (R.style.DefaultCustomViewStyle) if I still have to supply default value while retreiving it?

val typedArray = context.obtainStyledAttributes(
    attrs,
    R.styleable.CustomView,
    defStyleAttr, 
    R.style.DefaultCustomViewStyle)
val color = typedArray.getColor(
    R.styleable.CustomView_ss_iconColor,
    defValue)
READ ALSO
How do you track screens as pages on Google Analytics? (website view using app data)

How do you track screens as pages on Google Analytics? (website view using app data)

We have an Android app we'd like to track pages using Google Analytics withI've integrated the Google Analytics SDK through Play Services 17

35
Notification not receive when Application terminated in android

Notification not receive when Application terminated in android

I use firebase push notification to device tokenWhen app is opening or in foreground I can get notification well

53
How do I connect an Azure MySQL Database to my iOS and Android App

How do I connect an Azure MySQL Database to my iOS and Android App

Entirely new to this and was hoping to find some reasonably straightforward API's or documentation to connect the MySQL database I have on Azure to the iOS and Android apps I have in development

22
why Dialog doesn't show in Kotlin?

why Dialog doesn't show in Kotlin?

I want to create a Dialog window when I click the Floating Action ButtonBut, when I click the button, just appears the Toast message

36