Kevin
04/04/2022, 4:06 AMactivity_main.xml
in form of <com.test_project.library.buttons.TestButton/>
, it did works perfectly, but i found out that i cannot override the text value because the android:text
doesn't appear from suggestion.
is this because the effect from inflating the views? or there is something that missing from the custom views class that i didn't declare it first so i cannot put text value in activity_main.xml
?class TestButton : RelativeLayout {
constructor(context: Context) : super(context) {
initView()
}
constructor(context: Context, attr: AttributeSet? = null) : super(context, attr) {
initView()
}
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int
) : super(context, attrs, defStyleAttr) {
initView()
}
private fun initView() {
val rootView = (context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater)
.inflate(R.layout.activity_button_default, this, true)
}
}
Rob Elliot
04/04/2022, 8:32 AMKevin
04/04/2022, 8:41 AM