Button Press in jetpack compose showing multiple recomposition - android

Hello the code is very simple on pressing a button i am changing the mutableState value.But i found the on button press recomposition is happening multiple time.
So is this some bug or for button the property is a bit different

Related

prevent button click from being recognized on underlying composable

I am using Jetpack Compose and have a composable with a video player. When you tap the screen I have a listener that pauses the video.
On the top of the screen I have a top AppBar with an icon button.
When I tap the icon button the onClick fires but then the click is also consumed by the underlying composable, in my case the video player, so the video is also paused.
Question:
How do I make the icon button be the only composable that consumes the click? I do not want any other view to detect the click.
I am new to Jetpack Compose and cannot find any information on how to prevent this from happening.

Backpress in Jetpack Compose resets the status of the previous screen

I am currently migrating my old Android app (based on xml-views) to Jetpack Compose. I use a Single Activity for all my composables (views). I use a NavController to navigate. There is something that is not clear to me:
In classic xml views, when you scroll or enter something in a text field on a particular screen for example, and you open a new Activity, and you press the backbutton, the scroll position and the text entry on the previous screen is still visible. In Compose, the screen is reset to its starting position when pressing backbutton. For some screens this is not a problem, but for others it is. Can someone help me how to solve this in Compose?

react native picker - doesn't hide when android back button pressed

I have a listener on the whole app for the back button press event in android to override the default behaviour of back button(exit the app).
Also in some component i have override it too if i want the back button to be disabled or do something else.
The problem is when i open a react-native-picker, the picker stays on the screen ignoring the back button press.
I want it to first close (on the first back button press) and only then do what the higher component ordered to do when back button is pressed.
so i can't override the the higher component back button handling
i thought maybe to add the picker as a screen in the navigator and instead of planting it as a component, navigate to it, so it will be added to the stack navigator.
then by default it will first pop it of the stack when pressing back.
how can i add the picker component as a screen to navigate to, or is there a better way to do that?
By default the back behavior collapses or closes the picker on Android (depending on the mode you have chosen). You can see a working example here.

Prevent losing focus on EditText when clicking on a button in Android

I'm writing a custom EditText that will have functionalities to bold/italic/underline/lists .... for Android
It's working so far so good but I've a problem that when a user clicking on a Button (for styling bold/italic...), the user will lose focus on the EditText.
Anyone has any ideas how to prevent the button taking focus from the EditText?
Thanks :)
The easiest thing to do would be to have the onClickListener of those buttons refocus the edit text as their last instruction.
You can also try putting focusable=false (and focusableInTouchMode=false) on the buttons. That may work, I'm not sure if focus is removed from the edit text when the screen is touched or when another item receives focus, which is subtly but important difference here. It would also slightly change any drawables on the button that use focused state.

What means this button state when my activity starts?

When my activity starts the button starts as below image, seems that it is selected.
button seems to be selected http://kodeinfo.com/wp-content/uploads/2014/03/post4_1.jpg
Button seems to be selected but I don't select it neither on activity nor layout.
I had checked and this is not related to focus. I tried starting the activity with requestFocus() on a button and does not have the same behavior.
Does anyone knows what is that? What is this state for the button? I don't want this behavior in my app, but I'm not being able to understand the issue in my code because I don't know what this state is.

Categories

Resources