I’m writing an Android application in Android Studio on Java.
I know that there is android:focusable="false"
, but I have too many files for doing this with every tag in XML.
How can I prevent all of them from being focused? Or maybe there is some ways that I can do it easier?
Advertisement
Answer
The only way I could think of is creating BaseActivity and BaseFragment classes and in onCreate and onViewCreated recursively go through all the views and call setFocusable(false).
Here is an answer how to do it recursively:
Loop through all subviews of an Android view?
Also here I handled a case with a recursion myself. I have posted an answer: