How to set default value for string in attributes at declare-styleable
I'm setting some attributes with declare-styleable to make a custom view. One of this attributes is a string. What I want to do, is that if I dont set a value in XML for thiks attribute, give it a default value but I don't know how to do it.
In my custom view Im doing this:
private var title = ""
init{
val styledAttr = context.obtainStyledAttributes(attrs,R.styleable.MyCustomView)
title = styledAttr.getString(R.styleable.MyCustomView_title)!! //I cant remove "!!" or I get...