I am using multiple fragments. I am adding fragment over fragment as below
supportfragmentmanager
.beginTransaction()
.add(R.id.container_login, newFragment, newFragment.javaClass.simpleName)
.addToBackStack(newFragment.javaClass.simpleName)
.commitAllowingStateLoss()
Now the issue is, despite of adding new fragment, previous fragment is not losing focus. Typing in edittext of current fragment types in previous fragment edditext.
Even action next also loses focus in current fragment and moves cursor in previous fragment.
Kindly help.
The fragment does not lose focus because you use .add method which adds the new fragment over the one which already exists in the container.
Use .replace() method which replaces the existing fragment from the container. This is similar to calling remove(Fragment) and then use .add() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With