自动对焦接下来的TextView [英] Focus next textview automatically

查看:155
本文介绍了自动对焦接下来的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的TextView Android版本:最大长度设置为 3 和另一个具有 Android版本:最大长度设置为 7

I have a TextView with android:maxLength set to 3 and another with android:maxLength set to 7.

我要集中自动移动到第二个的TextView 一旦第一<$ C $的 3 字符C>的TextView 被填满。如何实现这一点没有继承的TextView 和编写自定义实现?

I want focus to automatically move to the second TextView once the 3 chars of the first TextView are filled up. How to achieve this without inheriting TextView and writing a custom implementation?

推荐答案

我还没有尝试过,但是这可能工作。

I haven't tried but this might work.

设置一个监听器触发当文字被改变,这种用途

Setup a listener to fire when the text was changed, for this use

addTextChangedListener(TextWatcher watcher)

在此基础上的文字长度,你可以请求焦点更改到下一个字段。

Then based on the text length you can request the focus change to the next field.

。这实际上并没有给予重点这一观点。

If you want to find out the next field you can call View.focusSearch(View.FOCUS_FORWARD) Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.

这篇关于自动对焦接下来的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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