android-edittext

Android can't get EditText getText().toString() in a Dialog

孤者浪人 提交于 2019-12-01 10:39:15
I'm trying to create a custom Dialog in an individual class. The dialog is started in the main activity: DialogLogin login = new DialogLogin(); login.show(getFragmentManager(), DISPLAY_SERVICE); On starting the application the main activity starts in the background and then the dialog starts. In the dialog there is an EditText-field to receive user-input. On pressing the save-button the EditText-field should be read-out and the input displayed, but it's always empty. Moreover there are no errors in the LogCat... I tried many solutions of the same problem, but nothing worked. I hope anyone has

Android EditText value to integer

↘锁芯ラ 提交于 2019-12-01 10:37:14
I am creating a mortgage calculator android program and I was trying to figure out how to get the EditText value (comes back as an Editable) to convert to an integer so I can use those integers in the calculation of the mortgage. I know that there is a toString() method. Would that be the way to go and then try to convert it from a String to an integer? Integer i = Integer.valueOf(String s); You should also configure the EditText to only accept integer values. 来源: https://stackoverflow.com/questions/4197356/android-edittext-value-to-integer

Android: In browser edit text behavior

会有一股神秘感。 提交于 2019-12-01 10:20:50
问题 I have next problem: I try to process input in field, that displayed in browser, for example in text field for search in www.google.com. But for Android 4.1.2 and above that type of fields work with some problems with InputConnection. - it return null for ic.getExtractedText() however ic.getTextBeforeCursor() return normal value; - when i use ic.sendKeyEvent() for backspace it doesn't make effect until call ic.endBatchEdit(); But for regular edittext or in Android 2.3.3 it return correct

Prevent EditText from automatically focusing

≯℡__Kan透↙ 提交于 2019-12-01 10:12:21
I have an Android activity and there is one EditText in the whole layout. For some reason, whenever the activity starts, the keyboard comes up. I have tried all of the following things: Placing these two in OnStart : FindViewById<EditText> (Resource.Id.searchText).ClearFocus (); FindViewById<EditText> (Resource.Id.searchText).Selected = false; Adding a LinearLayout with these two properties: android:focusable="true" android:focusableInTouchMode="true" Adding the following tag inside another View on the layout: android:focusable="true" android:focusableInTouchMode="true" Adding this to my

Adding text from edit text field into an email

﹥>﹥吖頭↗ 提交于 2019-12-01 09:32:48
I have an app and want to have a contact us for where the user inputs their name, address, phone number, and a comment section. Then they will click on compose mail button and it will load the text into the email automaticlly. have some of the code worked out but not sure how to get the text from the edit text into my email msg. anyone have any suggestions on how i can do this. I have attached the code from my xml file and my java file. import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class

Android Thread modify EditText

五迷三道 提交于 2019-12-01 09:17:10
I am having a problem with modifying EditText in another function started by the thread: Thread thRead = new Thread( new Runnable(){ public void run(){ EditText _txtArea = (EditText) findViewById(R.id.txtArea); startReading(_txtArea); } }); my function is as follows: public void startReading(EditText _txtArea){ _txtArea.setText("Changed"); } It always force closes while trying to modify the edittext. Does someone know why? UI views should not be modified from non-UI thread. The only thread that can touch UI views is the "main" or "UI" thread, the one that calls onCreate() , onStop() and other

Android EditText value to integer

自古美人都是妖i 提交于 2019-12-01 09:04:32
问题 I am creating a mortgage calculator android program and I was trying to figure out how to get the EditText value (comes back as an Editable) to convert to an integer so I can use those integers in the calculation of the mortgage. I know that there is a toString() method. Would that be the way to go and then try to convert it from a String to an integer? 回答1: Integer i = Integer.valueOf(String s); You should also configure the EditText to only accept integer values. 来源: https://stackoverflow

How to pinch zoom an edittext in android?

烂漫一生 提交于 2019-12-01 09:02:52
问题 Please suggest a way to zoom all the contents of the edittext when a pinch gesture is detected. Want to zoom like typical text editor apps like KingSoft and quickoffice. 回答1: It's going to be nasty, but you can subclass EditText . In your subclass, override onTouch and pass its values to a ScaleGestureDetector . Store the detected scale as a member variable. Override onDraw , and call canvas.scale() with your scale value prior to calling through to super.onDraw . This is likely to wreak havoc

Android: How to enable my button back if EditText is not empty?

自闭症网瘾萝莉.ら 提交于 2019-12-01 09:01:58
I have 2 EditTexts; 01 and 02. My button will be disabled once the activity is started and when these two EditText contain text, the button has to be enabled again. However my button is always disabled and can't enable it using button.setEnabled(true); . Can anyone help me with this? summit.setEnabled(false); buttonEnable(); public void buttonEnable(){ if (feedback.length()>0 && email.length()>0){ summit.setEnabled(true); }else{ summit.setEnabled(false); } } You're correct about needing a TextWatcher. The afterTextChanged(Editable) method is the one you're interested in for something like this

How to use ruled/horizontal lines to align text in EditText in Android?

孤者浪人 提交于 2019-12-01 08:57:37
问题 Basically I want to do something like this in Android: I am trying to draw horizontal lines in a custom EditText , and then typing on these lines. I am using the text size for the distance between two horizontal lines . However, the size of cursor and that of text is not same . Hence, I am not able to maintain placing text "on" these lines. The alignment of the text base to these horizontal lines are not coming as proper. Here is the code used for drawing the lines:- float textSize =