Get text from an EditText

爱⌒轻易说出口 提交于 2019-12-23 18:18:39

问题


In my app I have an EditText that I want to get the value out of when it looses focus. How should I do this?

Thanks!


回答1:


Along the lines of this should work.

EditText.setOnFocusChangeListener(new View.OnFocusChangeListener()
{ 
   @override
   public void onFocusChange(View v, boolean hasFocus)
   {
       if (!hasFocus) {
           string value = (EditText) v.getText().ToString();
       }
   }
}


来源:https://stackoverflow.com/questions/7612069/get-text-from-an-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!