loloof64
04/17/2021, 4:58 PMloloof64
04/17/2021, 4:59 PMloloof64
04/17/2021, 5:00 PMprintln
output in Logcat.YASAN
04/17/2021, 6:33 PMupdateOrientation(resources.configuration.orientation)
fun updateOrientation(orientation: Int) {
_isPortrait.postValue(orientation == Configuration.ORIENTATION_PORTRAIT)
}
private var _isPortrait = MutableLiveData(true)
val isPortrait: LiveData<Boolean> get() = _isPortrait
YASAN
04/17/2021, 6:35 PMloloof64
04/17/2021, 8:51 PMremember{mutableStateOf(____)}
loloof64
04/17/2021, 9:49 PMonConfigurationChanged()
YASAN
04/18/2021, 4:21 AMonConfigurationChanged()
but you can easily update your variable after the view is recreatedloloof64
04/18/2021, 11:33 AMonConfigurationChanged()
then I need to wrap the composable into a real activity. So, I'll need to read some resources before.
Thank you ๐loloof64
04/18/2021, 11:49 AMclass ProcessDeathActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// This is an extension function of Activity that sets the @Composable function that's
// passed to it as the root view of the activity. This is meant to replace the .xml file
// that we would typically set using the setContent(R.id.xml_file) method. The setContent
// block defines the activity's layout.
setContent {
// Column is a composable that places its children in a vertical sequence. You
// can think of it similar to a LinearLayout with the vertical orientation.
Column {
TitleComponent("Enter your credit card number below")
ProcessDeathComponent()
}
}
}
}
~~So all I have to do, is to create an Activity, and use setContent (as well as its import declaration).
Also I may need to change the default activity in my AndroidManifest.xml~~loloof64
04/18/2021, 11:52 AMonConfigurationChanged()
loloof64
04/18/2021, 12:15 PMloloof64
04/18/2021, 12:17 PMisLandscape
. But in that case, how can update the state of MainPage from inside the onConfigurationChanged
method ?YASAN
04/18/2021, 12:19 PMloloof64
04/18/2021, 12:21 PMonConfigurationChanged
YASAN
04/18/2021, 12:22 PMYASAN
04/18/2021, 12:23 PMonConfigurationChanged
myself as well - although the end result wont be differentloloof64
04/18/2021, 12:26 PMlouiscad
04/18/2021, 12:39 PMloloof64
04/18/2021, 12:47 PMlouiscad
04/18/2021, 12:53 PMloloof64
04/18/2021, 12:56 PMGabriele Mariotti
04/18/2021, 7:58 PMval configuration = LocalConfiguration.current
when (configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> {
//...
}
else -> {
//...
}
}
loloof64
04/18/2021, 8:27 PMloloof64
04/18/2021, 8:28 PMloloof64
04/18/2021, 8:29 PMloloof64
04/18/2021, 8:30 PMColumn {
Row {
Button
Button
Button
}
Row {
Button
}
CustomSquareComponent{}
}
loloof64
04/18/2021, 8:32 PMRow {
Column {
Button
Button
Button
}
Column {
Button
}
CustomSquareComponent{}
}
loloof64
04/18/2021, 8:33 PMGabriele Mariotti
04/18/2021, 9:35 PMrememberSaveable
instead of remeber
?Gabriele Mariotti
04/18/2021, 9:35 PMremember
ย helps you retain state across recompositions, the state is not retained across configuration changes.Gabriele Mariotti
04/18/2021, 9:36 PMloloof64
04/18/2021, 9:38 PMloloof64
04/18/2021, 9:39 PMval
, instead of a stateloloof64
04/18/2021, 9:40 PM