Android的:两个EditTexts依赖对方 [英] Android: Two EditTexts dependent on each other

查看:133
本文介绍了Android的:两个EditTexts依赖对方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个EditTexts。一个用于以℃例如温度,而另一个是在°F的温度。当用户编辑1 EditTexts我想其他相应地改变。

I have two EditTexts. One is for example temperature in °C and the other is temperature in °F. When user edits one EditTexts I want the other to change accordingly.

问题是,这种变化使循环,其中EditTexts使对方的改变。如何解决此问题?我想还有其他的EditText反应当我改变第一个编程连,但没有环......

Problem is that this changes make loop, where EditTexts make changes of each other. How to solve this? I would like to still have reaction in other EditText when I change the first one even programmatically, but without loop...

推荐答案

检查每个的EditText 具有焦点第一个也是唯一改变它编程,如果它不具有焦点。

Check if each EditText has focus first and only change it programmatically if it doesn't have focus.

http://developer.android.com/reference/安卓/浏览/ View.html#hasFocus()

的其中之一由用户编辑将具有焦点。另一种则不会。

The one being edited by the user will have focus. The other one won't.

这篇关于Android的:两个EditTexts依赖对方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆