I have an Edit Text box, with the Input Type set to DECIMAL_NUMBERS. I have declared a global Int that I want to add the value entered in the edit text box to.
I have generated an EnterPressed member for the Edit Text box, but don't know how to access the value entered in the box so I can use it.
Also, do I need to clear the box manually? If so, how do I do that?
Small steps, big journeys. :)
Edit:
Okay, your doofus alarms must have being going off there. :)
It turns out that to get the value from an Edit Text box called eg MyNumber, all I need to do is access MyNumber.Text
Also to clear the box, MyNumber.Text = "" after retrieving the value entered works.
Ahem. :)
Related
I have a registration form, when I select an especific option on input, a textField this form receive a value that cannot be changed, being able to only type with other values in this textField.
If you want to have a text field only the app can update (and the user can't type into), use a TextView.
If you want them to be able to type into it, but you want to be able to set a value and "lock" it so they can't edit it anymore, you can use an EditText and do enabled = false. That also greys out the field - if you don't want that, you can do inputType = EditorInfo.TYPE_NULL to prevent the keyboard from appearing.
If you want a fixed set of options that the user can choose from, you can use an AutoCompleteTextView or the Material Components equivalent
I think I'm missing something very obvious here.
All I want is a field where users can enter a parameter that affects the app, for example -100
I want the field to be visible on the screen, displaying the current value of the parameter, but not with a cursor in it or underlined in red or anything. Simply visible, but if the user wants to change the parameter, they can click in the box and change the value.
Many thanks for your help!
You can try to add both TextView and EditText in your layout, then show and hide based on your need.
Just show EditText by default and add TextWatcher on it, when enter is pressed or saved, then show your TextView with value from EditText. Then write onClickListener for TextView to show EditText again.
Hope that makes sense.
In my app I have a couple of checkboxes, that when checked combine the first part of an edittext. In the same edittext I would like to allow the user to append some text, while disallowing to delete the built text.
This is how it looks
[This part is build from checkbox combination, and can change in real time][This part is user defined]
Now is there a way to not allow the user to modify the first part of the edittext, but still allow the app to change this text?
You can certainly create a TextWatcher object and add it to your edittext. In your textwatcher, you can store the constant text information in an instance variable. Then, you can fill in the onTextChanged() and afterTextChanged() methods to create the type of behavior you are looking for.
For example, you can check the cursor position (using editText.getSelected()) to see if the user tried to change some of the text that shouldn't be changed-- if they do, then have some code to handle the case.
I know this isn't the best answer, but I don't yet have privilege to make a comment. Hope this helps!
I have placed an edit box and in that box the user has to type his email id and when he clicks a button it must be send to network.
When the user starts typing his name it gives some suggestions above the default keypad of the device, if the user selects one among them a small space appears after the name that gets selected.
If it is to be the last name no problem but if he is to type anything next to the word it goes on with a space and it creates problem in getting return data from network.
how to disable the the word suggestions....
Try textNoSuggestions value for the android:inputType attribute.
For example:
android:inputType="textFilter|textMultiLine|textNoSuggestions"
You need to set the input type to no suggestions. There is also an input type for email addresses. From 2.1 on, the input type can be set in the layout.
Hi friends
I have an editable text box with a default value like to display to the user like "entername". If the user touches the edit box, I want to clear the value of edittext box and show the virtual keypad to the user, and if the user presses the enter key, only in the edit text box, I have to start another activity. How do I do this?
Hi in android:hint at the type of key pressing only it clear value I want to on touch in edit text box clear value and show virtual keypad to user. How do I do this?
Thanks
What?
I really don't understand what you're asking, but it seems like you might be trying to do a hint? Rather than setting an onTouchEvent listener, add a android:hint="What to do" attribute to your EditText.
U use the following code
EditText EditTextName=findViewById(R.id.EditText01);
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(EditTextName), 0);
use this code in ontouchListener of EditText
Mohan if I am correct you have two questions here
How to display a hint in an edit box
How get some data from a web service
For the first question you can use android:hint="Enter Name"
For the second one you need to give us more info on what you are trying to do