简体   繁体   English

在Android中按下软键盘上的Enter键后,TextView变得可编辑

[英]TextView getting Editable on pressing enter on soft keyboard in android

I am having an edit text so that user can enter amount in that and a text view below the edit text which calculates the tip amount and below this text view is an edit text in which a user can enter total amount. 我有一个编辑文本,以便用户可以在其中输入金额,并且在计算小费金额的编辑文本下方的文本视图和在此文本视图下方的是用户可以输入总额的编辑文本。 The problem is on entering the amount in 1st edit text and pressing enter on the soft keyboard the cursor does not point to the text view but cursor gets hidden (ie its focus is neither of the edit text) and on entering digits the editing starts in the text view. 问题在于在第一个编辑文本中输入金额,然后在软键盘上按Enter键,光标没有指向文本视图,而是光标被隐藏(即,它的焦点既不是编辑文本),又在输入数字时开始编辑文本视图。 I do not want this to happen the values in the textview should not be entered by the user. 我不希望这种情况发生,用户不应在textview中输入值。 I have added text watcher on the second edit text ie the total amount edit text which manipulates the values in the text view. 我在第二个编辑文本上添加了文本监视程序,即在文本视图中操纵值的总量编辑文本。 Thanks in advance 提前致谢

@Nishit , please post your layout ... because i dont think that you can write in text view @Nishit,请发布您的布局...因为我不认为您可以在文本视图中编写

but before this , please try and set 但在此之前,请尝试设置

in your xml_layout : inside EditTextView : android:maxLines="1" . 在您的xml_layout中:在EditTextView中: android:maxLines="1" it is only for clearing your doubt . 这只是为了消除您的怀疑。

i guess you are implementing onTextChanged and calculating the tip amount and setting it to the textview. 我猜您正在实现onTextChanged并计算提示金额并将其设置为textview。 so whats happening is for every digit you enter onTextChanged is executed and textview value gets changed is this whats happening if not post your code we will help you 所以发生的事情是对于您输入的每个数字onTextChanged都会执行,并且textview的值会更改。如果不发布您的代码,这会发生什么,我们将为您提供帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM