wintersoldier
04/01/2022, 2:00 PM@Composable
fun CustomTextViewCompose(
customText: String
) {
Text(text = customText)
}
--------------------------------
class CustomTextView(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : AbstractComposeView(context, attrs, defStyle) {
var textString by mutableStateOf("")
@Composable
override fun Content() {
CustomTextViewCompose(customText = textString)
}
}
This is a very pretty basic sample , when it comes to button and all you may have to update the text and do other things to , how to handle those scenarious?Adam Powell
04/01/2022, 2:30 PMwintersoldier
04/01/2022, 3:15 PM<app.textview.CustomTextView-->
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvCustom"/>
binding.tvCustom.apply{
//here how can I make this property as mandatory //,if I didn’t pass textString how
}.wintersoldier
04/01/2022, 5:47 PMmyanmarking
04/01/2022, 6:39 PMAdam Powell
04/01/2022, 8:29 PMval currentTextString = textString
if (currentTextString == null) {
Text("textString wasn't set!", Modifier.background(Color.Red), style = TextStyle(color = Color.Yellow))
} else { ...