TextView中有一个单一的,可编辑的行 [英] TextView with a single, editable line

查看:115
本文介绍了TextView中有一个单一的,可编辑的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做在Android控制文本后面的反复互动。这个想法是有这样的事情:

I'd like to do textual back-and-forth interaction in an Android control. The idea is to have something like this:

这是一些程序的输出文本。

This is some text output by the program.

你叫什么名字? |

用光标在 | (注意,编辑最后一行的开头不启动)。然后,用户可以自由输入文字(使用任何的Andr​​oid输入法,键盘等),但不允许更改任何输出为止。理想情况下,用户的输入会受到不同的风格。

with the cursor at | (note that editing doesn't start at the beginning of the last line). The user is then free to enter text (using whatever Android input method, keyboard, etc.) but isn't allowed to change any of the output so far. Ideally, the user's input would be styled differently.

然后,一旦输入换行符,我要通知程序和编辑,以停止:

Then, as soon as newline is entered, I want the program to be notified and editing to stopped:

这是一些程序的输出文本。

This is some text output by the program.

你叫什么名字? 美孚酒吧

您好,富吧!

请注意,这需要一个适当的控制,即,一个我可以与其他控件组成,使其只是一个应用程序的主要布局的一部分。

Note that this needs to be a proper control, i.e. one I can compose with other controls to make it just one part of the app's main layout.

推荐答案

我会建议你创建一个新的LinearLayout(+的TextView EditText上),并分配一样的EditText布局的背景和EditText上没有背景。
在做的EditText,你可以在底部显示一个新的TextView

I would suggest you to create a new LinearLayout(TextView + EditText) and assign the background of layout like EditText and edittext's no background. Upon editText done, you could show a new TextView in the bottom

这篇关于TextView中有一个单一的,可编辑的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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