Android版的EditText全选()不工作,如果一个在Android中4.x的同场只水龙头 [英] Android EditText selectAll() doesn't works if one taps on the same field in android 4.x only
本文介绍了Android版的EditText全选()不工作,如果一个在Android中4.x的同场只水龙头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要选择的所有文本$ P $中的EditText领域psent如果点击一样,现在我可以通过下面code在android系统2.x和3.x实现这一目标,但不是在4.0。如果任何一个有同样的问题,请让我知道如何解决这个问题。
@覆盖
公共无效onFocusChange(视图V,布尔hasFocus){
开关(v.getId()){
案例R.id.pass codetext1:
如果(hasFocus)editText1.selectAll();
打破; 案例R.id.pass codetext2:
如果(hasFocus)editText2.selectAll();
打破; 案例R.id.pass codetext3:
如果(hasFocus)editText3.selectAll();
打破; 案例R.id.pass codetext4:
如果(hasFocus)editText4.selectAll();
打破;
}}
解决方案
我刚好layout.xml增加一个属性解决了这个。
的android:selectAllOnFocus =真
早些时候,我不知道这一点,但这个真的是对这类问题的一个很好的解决方案。
I want to select all the text present in EditText field if one clicks on the same, right now i can achieve this by below code in android 2.x and 3.x but not in 4.0. If any one had the same problem please let me know how to resolve this.
@Override
public void onFocusChange(View v, boolean hasFocus) {
switch(v.getId()) {
case R.id.passcodetext1:
if(hasFocus) editText1.selectAll();
break;
case R.id.passcodetext2:
if(hasFocus) editText2.selectAll();
break;
case R.id.passcodetext3:
if(hasFocus) editText3.selectAll();
break;
case R.id.passcodetext4:
if(hasFocus) editText4.selectAll();
break;
}
}
解决方案
I solved this by just adding one property in layout.xml.
android:selectAllOnFocus="true"
Earlier i was not aware of this but this is really a very good solution for this kind of problems.
这篇关于Android版的EditText全选()不工作,如果一个在Android中4.x的同场只水龙头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文