Button(onClick = { /*Button action.*/ },
content = { Text(text = "Button Text") })
Here is the same Button element written using trailing lambda notation:
Button(onClick = { /*Button action.*/ }) {
Text(text = "Button Text")
}
var newCaption = rememberSaveable { mutableStateOf("Click Me") }
// Read the entire file into a string:
val s = inputStream.bufferedReader().use {
it.readText( )
}
// Read the file line by line:
var s = ""
inputStream.bufferedReader( ).useLines {
lines -> lines.forEach {
line -> s += line + "\n"
}
}
// Or
var s = ""
inputStream.bufferedReader( ).useLines {
it.forEach {
s += it + "\n"
}
}
Look at the WriteToFile JPC Example to see the last construct used.caption : String, clickListener : ( ) -> UnitUse CustomButton to add three buttons to the app. Also add a Text element. The first button should have the caption "Button A" and its click listener should show the message "Button A clicked" in the Text element. Same for buttons B and C.
drawLine drawCircle drawRectHere are these functions with their required and optional parameters. Required parameters and some optional parameters are shown with sample values. Look up other optional parameters as needed.
drawLine(
color = Color.Blue, // Required
start = Offset(x=5f, y=5f), // Required
end = Offset(x=120f, y=150f), // Required
strokeWidth = 1f // Optional
)
drawCircle(
color = Color.Red, // Required
radius = 50f, // Optional
center = Offset(x=100f,y=75f),// Optional
style = Stroke(width=10f) // Optional
)
drawRect(
color = Color(0xFF000080), // Required
topLeft = Offset(x=50f,y=50f),// Optional
size = Size(x=95f,y=95), // Optional
style = Fill // Optional
)