简体   繁体   中英

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. I do not want this to happen the values in the textview should not be entered by the user. 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

but before this , please try and set

in your xml_layout : inside 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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