3

在我的应用程序中,我有一个在SortedMap. 该活动作为ListActivity. 我已经ArrayAdapter为收集项目实现了自定义。

每个ListView项目(对应于基础记录)由TextViews、EditTexts 和 a组成,Button用于删除记录本身。布局大致如下:

ListView
----------------------------------------------------
[TextView] [EditText] [TextView] [EditText] [Button]
----------------------------------------------------
[TextView] [EditText] [TextView] [EditText] [Button]

我的目标是在用户完成编辑后立即处理用户输入到EditTexts 的输入,即当用户离开 sEditText或用户按下回以关闭屏幕键盘时。

我已经尝试通过处理来实现这一点onFocusChanged,以处理EditText. 但是这种方法效果不佳,onFocusChanged方法被非常频繁且随机地调用,即使对于 unselected & unedited EditTexts 也是如此。这可能是由于这个StackOverflow 问题的 Android 博客上的这篇文章

有一个更好的方法吗?

4

1 回答 1

2

TextView, which EditText extends, includes the method public void addTextChangedListener (TextWatcher watcher) that may be useful to you.

I have not used it before but it seems like this would be called anytime the user edits the TextView and then you could process it every time it changes. This may cause a lot of overhead if it is called every time a user deletes or adds a character, but it may be the easiest solution.

于 2011-01-14T23:30:04.757 回答