android - EditText: show input window, retrieve text, and change its height -
In my project, I have a list of the products available in the table-layout. I need two things.
- When a user clicks on
EditText , the numeric keypad should be displayed below.- After entering the user numeric value, how can we get edit text box value?
I have
EditText such as:EditText txtQty = new EditText (this); TxtQty.setTextSize (2, 12); TxtQty.setHeight (4); TxtQty.setWidth (6); TxtQty.setId (i); TxtQty.setInputType (InputType.TYPE_NUMBER_FLAG_DECIMAL); TxtQty.setText ("0.00"); Tr.addView (txtQty);- How can we reduce
EditText box height? I did, but he did not make much change
Please give me an idea ...
Thank you in advance
You can use 2 events to get it. First of all, the test has been shaken if you edit, every time you want to get text from the editing text. The second is the OnDownLastner, you can check whether the key is equal to entering or not. GetText () ToString () is used to obtain the text of the editing text, here is a code snippet:
myEditText.setOnKeyListener (new view onkelister () {@ Override public boolean on (see V, int kikod, key event event) {if ((event.getAction) == KeyEvent.ACTION_DOWN) & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; ; & Amp; amp; amp; keycode (= KeyEvent.KEYCODE_ENTER)) {string tmp = draw.myEditText.getText (). ToString (.) Trim (); // Keyboard InputMomment Imm = (InputMethodManager) GetSystemService (Context.INPUT_METHOD_SERVICE); Imm.hideSoftInputFromWindow (myEditText.getWindowToken (), 0);} return false;}});
- After entering the user numeric value, how can we get edit text box value?
Comments
Post a Comment