My situation is: I have a EditText
, and under it I have a button, called "select all". It's purpose is to let the user select all the text by pressing it.
When the button is clicked, I invoke selectAll()
on the EditText
, but instead of selecting all text, in some cases (generally, when the cursor is already positioned within the text somewhere), the cursor is moved to position 0
(start of text) and text remains unselected. Second click on the button will then select all. But of course it should happen on first click.
From this issue: Android EditText selectAll() doesn't works if one taps on the same field in android 4.x only it seems that this is a bug in android 4.0 and above. (Found no mention in Google issue tracker).
Does anyone know about a way to overcome this problem? It seems that the probelm is also in other selection methods and not only selectAll()
.
(p.s. This question is sort of duplicate of the issue I mentioned above. But I opened another question, because the author of that issue was satisfied and selected a partial answer (of setting android:selectAllOnFocus="true"
), while in my case and scenario it does not help me and does not solve the problem.
Thanks.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Try this:
Or This:
Or this:
Or this:
Hope this helps .. :)
I was having a similar issue. I solved it (using Xamarin in C#, but the equivalent Java will work) with the following code:
I have 2 controls: One is a dropdown that lets you select a chicken house and then a set of buttons for each day of the week. Whenever you change the day of week or the chicken house, I want to set focus in the
txtMaleCount
EditText
and then I want the value in that box selected (since it's a number and they're presumably going to replace it).Clearly, the non-intuitive part was the need to
Post
it. Doing it directly (on the UI thread) didn't seem to have any effect.Problem caused by IME. If showed cursor drag pointer then selection must be zero width.
You need cancel drag pointer. It can be doned by change text. For example
replace
:We replace first symbol of text with same symbol. It cause cancel drag pointer and allow make selection without bug.