so I tried android:selectAllOnFocus and of course I'm using android:hint. The app loads, requestFocus triggers and the full text is selected.
The problem is that when I click in the EditText the selection is lost.
I've already read: Select all text inside EditText when it gets focus
We have used getText() method to get the text entered in the EditText views. But getText() method returns an Editable instance and therefore we have typecasted it to convert it into String for further use. This can be done by using the toString() method.
Android App Development for BeginnersA EditText is an overlay over TextView that configures itself to be editable.
For the above requirement the solution in XML is android:editable="false" but I want to use this in Java. et. setKeyListener(null); It makes the EditText not EDITABLE but at the same time it makes it non clickable as well.
For some reason, it worked (on Jelly Bean) only if I posted it with a Handler:
new Handler().post(new Runnable() {
@Override
public void run() {
paidView.selectAll();
}
});
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