单击EditText视图时如何选择所有文本? [英] How do I select all text when clicking on a EditText view?
本文介绍了单击EditText视图时如何选择所有文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我尝试了android:selectAllOnFocus,当然我正在使用android:hint.应用程序加载,requestFocus触发器并选择了全文.
so I tried android:selectAllOnFocus and of course I'm using android:hint. The app loads, requestFocus triggers and the full text is selected.
问题是当我单击EditText时,所选内容丢失了.
The problem is that when I click in the EditText the selection is lost.
我已经读过:在获得焦点时选择EditText中的所有文本
推荐答案
由于某种原因,它只有在我使用处理程序发布时,才能在Jelly Bean上运行:
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();
}
});
这篇关于单击EditText视图时如何选择所有文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文