Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Why does android edittext setfocusable do not work?


Asked by Araceli Tate on Nov 29, 2021 Android



I was basically doing this: The problem was though that the view would get focus again, but you couldn’t type anything. I googled around for a bit and noticed this was an issue that had been previously reported, but hadn’t been fixed yet. There is a way around it however, you just have to do:
Subsequently,
The EditText will be able to get the focus when the user touch it. When the main layout (activity, dialog, etc.) becomes visible the EditText doesn’t automatically get the focus even though it is the first view in the layout.
Additionally, android:editable="false" should work, but it is deprecated, you should be using android:inputType="none" instead. Alternatively, if you want to do it in the code you could do this : EditText mEdit = (EditText) findViewById (R.id.yourid); mEdit.setEnabled (false); This is also a viable alternative :
Accordingly,
android:editable="false" should work, but it is deprecated, you should be using android:inputType="none" instead. If you're going to make your EditText non-editable, may I suggest using the TextView widget instead of the EditText, since using a EditText seems kind of pointless in that case.
In fact,
As TextView is not focusable by default, we need to make it so explicitly: We don't need to do anything to res/drawable-v21/background.xml because the RippleDrawable already supports both focused and pressed states. Using Genymotion (or an emulator) is the most convenient way I've found to test non-touch input.