FAQ Database Discussion Community


How to get all text from dynamically added edittext in android?

android,android-edittext
I am new to android. Now i am need to know how to get text values of all edittext which has added dynamically when user press add button. add.setOnClickListener(new OnClickListener() { public void onClick(View v) { table = (TableLayout) findViewById(R.id.table); row = new TableRow(Material.this); table.setGravity(Gravity.CENTER); edit = new EditText(Material.this); edit.setWidth(135);...

How to get cursor to right edge of an EditText that has been programmatically edited since user put data into it?

java,android,android-edittext
I have 5 EditText fields. Wherever the cursor is positioned in the first 3 only before getting output from a dialog, it stays in the same position after the user gets output from a dialog. That's good. But for the last 2, the cursor is always positioned before the first...

Two simultanious edit texts on android

android,android-edittext
I am creating a unit converter for android. It has two edit texts and i want to update one as the user types in the numbers in the other but i can't get it. I have tried several methods but so far i can't get this to work. I am...

Get Input value from Edittext which generated dynamically

android,android-layout,android-edittext
I have to create n EditText where n is user input. I could create it using for loop. TableLayout tbl=(TableLayout)findViewById(R.id.TableLayout1); //table row for (int i = 0; i < 5; i++) { TableRow tr = new TableRow(this); TableLayout.LayoutParams tableRowParams= new TableLayout.LayoutParams (TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT); //for set margin tableRowParams.setMargins(0, 10, 0, 0); tr.setLayoutParams(tableRowParams);...

Android EditText Border Background Color

android,android-layout,colors,android-edittext,border
In My Application, I have set EditText with border background color and it works fine on all the devices, however on my 4.1.2 devices the whole EditText display as black color. I am able to enter text in it and everything works but text not visible because EditText is completely...

Else statement not running? Android

android,android-edittext
I have a code, that I implented onCreate in the MainActivity, and the problem is, that my code is not fully running, I mean the program only checks the if statement, and don't care about the else statement. Here's the code. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); input...

How to make EditText Hint right to left -sided?

android,android-edittext,hint
How to make EditText Hint right to left -sided I write Arabic word hint ,, and its showing on the left side ....

How to make EditText work like it does in Twitter Android App for status update

android,android-layout,android-edittext
How does twitter app handle the onclick action on EditText whenever we want to write a tweet? I want to know this because it lets us make a neat user interface and we can manage layout space in a better way. So my question is that when we click on...

Calculating percentages value of edittext in android

android,android-edittext
I have got the code to add the values of multiple edittext fields and display the total in one field. Now I need to include the percentage calculation of two more edittext fields along with the total value. editTexts = new EditText[] {monthly_rent_et, water_et,eb_et,sewage_et,maint_et,others_et,sec_deposit_et}; for (int i=0 ; i<editTexts.length ;...

How to prevent user from entering data in Edittext and enable Edittext to get data only from Dialog?

android,android-layout,android-activity,android-fragments,android-edittext
My requirement is that when user clicks on edittext, a dialog should pop up enabling the user to select one of the values from lit. The above portion has been accomplished. I do not want user to enter/edit any other value than values given in list in dialog. I want...

Is it possible to receive an EditText from an xml activity to java that's not connected to the xml?

java,android,xml,android-edittext
I have an XML that has an edit text on it, a java file connected to it that can receive the edit text and turn into a string no problem XML <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="10dp" android:paddingBottom="@dimen/activity_vertical_margin"...

android edittext does not show custom cursor when orientation change

android,android-edittext
I have a standard EditText which looks like this: <EditText android:id="@+id/message_body" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textMultiLine" android:gravity="top|start" android:background="@null" android:textCursorDrawable="@drawable/mycursor" android:minLines="3"/> Which is fine. It shows on the screen and works great but as soon as I change orientation from portrait to landscape, the editText changes to slightly different UI, with a "Done"...

Hint is not showing in Edit text in lower api

android,android-edittext,devices
EditText is not showing hint with the following XML code, it is working in some devices like mine is API 19, but not showing hint in android 2.3.3 <EditText android:id="@+id/street1ET" android:layout_width="match_parent" android:layout_height="30dp" android:layout_weight="1" android:layout_gravity="center_horizontal" android:layout_marginTop="10dp" android:background="@drawable/custom_edittext" android:ems="10" android:gravity="center" android:hint="@string/street1" android:inputType="text"...

Adding the values of the edittext in android

java,android,android-edittext
I have five edittext fields in which i ll be entering the amount values and one seperate field to display the total amount. Say, I enter 2000 in the first field and click on the second field, the 2000 will be set in the total field. The again if I...

Android - How to set numeric EditText to a specified number of digits

android,android-edittext
I want an EditText to contain exactly 8 digits (like bank accounts). Of course in addition to : android:inputType="number" Is there an option in XML or do I have to manage this programmatically ?...

how can create specific input type on edittext? The input accettable is Roman numbers M D C X V I

java,android,input,android-edittext
I' ve extend edittext class, how can create a custom input type to accept just this characters (M,C,D,X,V,I)? This is my class that extend EditText import android.content.Context; import android.util.AttributeSet; import android.widget.EditText; public class DecimalEditText extends EditText{ public DecimalEditText(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub }...

How can I allow specific strings in an edittext and show these string to the user?

java,android,android-layout,autocomplete,android-edittext
I have an EditText in a layout. I want to "allow" the user to be able to enter only a string that is part of a predefined set of string I have (an array of 8 strings). How would I show the user the only options to type that are...

Android EditText onClick Listener defined in Layout fails with obscure Exception

android,android-layout,android-edittext,android-event
I want to define an onClick Listener for an EditText in the Layout-XML of may activity, but it always fails with an obscure Exception. The Layout is injected with setContentView()in the onCreate-Method of my activity. I am not using a Fragment here and I am well aware that the XML...

How to filter the input of EditText?

android,android-edittext,textwatcher,android-input-filter
I want to filter the input of an EditText, only digits and letters are allowed, first I use TextWatcher to deal with the last input character, but when you move the cursor or you past some content to the EditText, this method failed, now I want to know is there...

How to convert uppercase letter to lowercase?

android,android-edittext,uppercase
I am creating one application,in my login page i am able to enter uppercase and lowercase letters both,what i want is if user enters letters in uppercase it should convert to lowercase,in short i dont want to allow user to enter uppercase letters <EditText android:id="@+id/email" android:layout_width="match_parent" android:layout_height="60dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:background="@drawable/f_name"...

Validating Blank EditText shows error

android,nullpointerexception,android-edittext,android-alertdialog
While I am validating EditText for login I am Getting NullPointerException public boolean onMenuItemClick( MenuItem item ) { if(item.getTitle().equals("Login")) { final String Usname; final String Pswd; Status=(TextView)findViewById(R.id.tvStatus); Uname=(EditText)findViewById(R.id.etLUsername); Pwd=(EditText)findViewById(R.id.etLPassword); LayoutInflater li = LayoutInflater.from(MainActivity.this); View promptsView = li.inflate(R.layout.login, null); //Usname=Uname.getText().toString(); //Pswd=Pwd.getText().toString();...

EditText auto suggestions are blank or non existing

java,android,xml,android-edittext
I have a standard straight forward EditText, I want to show the dictionary suggestions on top of this EditText so I did this in the XML: <EditText android:id="@+id/messaging_messageEdit" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="10dp" android:layout_weight="85" android:background="@drawable/clanz_edit_text_holo_dark" android:ems="10" android:hint="Type your message here..." android:singleLine="true" android:inputType="textAutoComplete"...

Back key or Delete key of Soft Keyboard not working in 4.4 and 5.0?

android,layout,android-edittext,android-softkeyboard,keyevent
I am facing the issue of back key or del key which is not working in 4.4 and 5.0.1 devices ? When I press the back key of softkeyboard below method is not calling. Username.setOnKeyListener(controller); Password.setOnKeyListener(controller); @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if(event.getAction() == KeyEvent.KEYCODE_DEL){ getActivity().setDisableLoginButton();...

Multiline EditText not scrolling vertically when virtual Keyboard is visible

android,android-edittext
I have EditText that is wrapping content as required; however, when the virtual Keyboard in visible on screen, I am unable to scroll the text vertically to display the lines on top that are hidden from view (e.g., first line when I am typing "android:lines"+1 line). When I hide the...

Horizonal LinearLayouts in a Vertical LinearLayout

android,android-layout,android-edittext,android-linearlayout,android-button
I want a few EditTexts with buttons on their right. Right now I just have the Edittexts filling the parent with the 0dp trick. If I add the button the height of the EditText will shrink with wrap_content. If I do match_parent one EditText fills the entire screen. RelativeLayout doesn't...

programming android: compare existing string wit editText text

android,android-edittext
I want to compare two strings in android studio. I have a textEdit and want to compare this string with a given string. But there is a little problem. So i do not find the mistake. In my oppinon it should work but there must be a error in the...

How to test IME_ACTION_DONE on Genymotion emulator

android,android-edittext,genymotion
In one of my apps I have an EditText that has android:imeOption="actionDone" set. I've also set the appropriate setOnEditorActionListener(). <EditText android:id="@+id/search_field" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/search_field_hint" android:imeOptions="actionDone" android:singleLine="true"/> When testing on a real device everything works great - I enter some text, hit the "Done" button and my action get's triggered. On...

Getting value of edittext into object

java,android,android-edittext
Hi I'm new to android programming and am running into a frustrating bug. I'm trying to get the value from an edittext and put it into an object. My code will print the value into Log.v but throws a NullPointerException when I try to use mEdit.getText().toString() in my setter method....

Cursor stays in the centre of edittext when increasing height

android,android-edittext
I am trying to make custom edittext: public class HeadedTintEditText extends EditText { private String headerText; private int headerSelectedColor; private float headerTextSize; private Paint textPaint; private int textColor; public HeadedTintEditText(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HeadedTintEditText, 0, 0); try { headerText = a.getString(R.styleable.HeadedTintEditText_headerText); headerSelectedColor =...

how can i change the EditText cursor knob color android (not the cursor color the knob)

android,android-edittext
I am trying to change my EditText cursor knob but failing to see it on a device, attached is my XML for this layout <EditText android:id="@+id/new_text_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:imeOptions="flagNoExtractUi" android:layout_marginLeft="16dp" android:layout_toLeftOf="@+id/new_text_button_send" android:background="@android:color/white" android:hint="@string/write_a_message" android:textSize="@dimen/text_size_large"...

Android: EditText in ScrollView goes of the screen when kayboard appears

android,android-edittext,scrollview
I am trying to create a login screen. I have used ScrollView to hold input fields. I have following xml: <RelativeLayout ... > <RelativeLayout android:id="@+id/top_menu" ... > <ImageButton ... /> <com.neopixl.pixlui.components.textview.TextView... /> </RelativeLayout> <ScrollView android:id="@+id/scroll_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/top_menu" android:overScrollMode="always"> <LinearLayout android:id="@+id/login_group"...

text validation on wizard droid

android,keyboard,android-edittext,wizard
I am using Wizardroid to add items to my main list view, the wizard contains 3 "pages" where in each one i have multiple edittext fields. i need to have text validation to the input since the fields cant be empty, therefore I used "addTextChangedListener". when the user enters text...

Cannot get text in Edittext in dialog

android,dialog,android-edittext
I write a method that show a dialog with a EditText and button and when button pressed My app should be get the value of EditText but for ever EditText is empty, Why? private void lookupNumber(){ final Dialog dialog = new Dialog(MainActivity.this); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialognumber); final EditText eNumber=(EditText)findViewById(R.id.getNumber); Button btnOk =...

I do not want the appearance of the writing pad, but when you press

android,android-edittext,android-keypad
I have a problem in Edittext, When you open the Activity , the clavier opened . I want the board not appear until you press it . example : http://i.stack.imgur.com/GppYS.png

Can't get EditText to get focus and popup keyboard

android,android-edittext
I am not able to set the focus on the EditText box at the end. I have tried almost every trick on google! I am not able to get it to focus nor am I able to bring the keyboard. I have also tried setting the android:windowSoftInputMode="adjustResize" but this also...

How to add text in between words in edittext when a button is pressed

android,button,android-studio,android-edittext
I cannot figure out how to add a space between every word the user types into an edittext as I am still a beginner. I have typed the obvious code below. findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText editText = (EditText) findViewById(R.id.editText); EditText editText2 = (EditText) findViewById(R.id.editText2);...

MaskedEditText cannot get text

java,android,xml,android-edittext
Sorry for my English. I am using the library MaskedEditText. Everything works fine, but I can get text(only text). Example: I have XML: <br.com.sapereaude.maskedEditText.MaskedEditText android:id="@+id/phoneNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="3dp" android:background="@null" android:inputType="number" mask:mask="(###) ###-##-##" > </br.com.sapereaude.maskedEditText.MaskedEditText> If the user enters text: (111) 111-11-11, I should get only 1111111111. Below is...

Allow accent character in Edittext using digits Android

android,android-edittext
I am using Edittext which is allowed to specific characters. Like a-z A-Z 0-9 and Special characters like )&'(". For the above requirement I used digits in Edittext to restrict rest of the other special characters getting typed. The digits not supported ' & " chars so I used html...

How to change the floating label color of TextInputLayout

android,android-edittext,android-design-library
With reference to the new TextInputLayout released by Google, how do I change the floating label text color? Setting colorControlNormal, colorControlActivated, colorControlHighLight in styles does not help. This is what I have now: ...

How to create an EditText that goes up with the Keyboard on Android

android,xml,android-edittext
I have been looking on how to create something similar the Image below, I created an EditText with an ImageView with icon " Send ", but I couldn't manage on how we can create something similar to this, something that goes up with the Keyboard. ...

Done key not showing up on keyboard

android,xml,keyboard,android-edittext
I am making an Android app and want the done key to show up on the keyboard when the user is typing into the keyboard. This is the XML code for the EditText: <EditText android:id="@+id/answer" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:gravity="center_horizontal" android:textColor="#ffffff" android:layout_marginBottom="113dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:imeOptions="actionDone" /> I...

How do I create a dictionary-like android app using HashMap for words and their respective meanings?

android,dictionary,android-edittext,hashmap,android-textview
I'm trying to create an app that works like a dictionary (using HashMap), where a user types in a word (jargon) in the textEdit and if that word matches any of the words in HashMap, will display my predefined meaning of the word in a textView when user hits enter....

Edittext on background fragment still editable

android,background,android-edittext
I have problem with using EditText with several fragments. I have two fragments: FragmentOne and FragmentTwo, and each fragment has EditText. After adding FragmentTwo above FragmentOne: android.support.v4.app.FragmentManager fragmentManager =getActivity().getSupportFragmentManager() fragmentManager.beginTransaction().add(R.id.frame,new FragmentTwo()).addToBackStack(null).commit; When I press Enter on keyboard, cursor goes to EditText on FragmentOne. How to fix it? Similar problem was...

Android EditText Symbol must remain at initial position

java,android,android-edittext,android-input-filter
I have a text field where the start symbol is $ (could be euro or pound depending on an application setting). I need to make it so that if the user clicks before the symbol nothing will happen. In other words, the selection must remain after the symbol. I tried...

Material Design: Change EditText's Color Dynamically

android,android-edittext,material-design
This is my material style <style name="AppTheme.Base" parent="Theme.AppCompat"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorControlNormal">@color/colorControlNormal</item> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> </style> If I create EditText (or other...

Scrollable Edittext in Listview in android

android,scroll,android-edittext
I am working on one of my Android project in which I am showing one Listview with Edittext inside Listview row. the problem is when I try to scroll Edittext, I can not do so as Listview will be scroll. How can I achieve scrollable Edittext in Listview. Here is...

Keyboard doesn't show on focus in alert dialog

android,dialog,android-edittext,focus,alert
I have a dialog which I extend from custom PopupDialog. The problem is that the keyboard won't appear on focus EditText field . I've tried with clearFlags and other things, but the problem is still there. public class PopupDialog<RESULT> extends AlertDialog { private final View mContentView; private final AppActivity mActivity;...

İf statement, Code not work . Please [duplicate]

android,string,button,if-statement,android-edittext
This question already has an answer here: How do I compare strings in Java? 23 answers final EditText yaz = (EditText)findViewById(R.id.editText); final Button bas = (Button)findViewById(R.id.button); yaz.setText("500"); bas.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String afd = yaz.getText().toString(); if (afd == "1000") { yaz.setText("2000"); } } }...

android edit text value passed directly as parameter to object functions or constructors not working

android,android-edittext
Below is the class code: public class UserInfo { String userName; String userPass; public UserInfo(){ } public UserInfo(String userName, String userPass){ userName=this.userName; userPass=this.userPass; } public void setUserName(String userName){ userName=this.userName; } public void setUserPass(String userPass){ userPass=this.userPass; } } If I pass the string to object function from an activity as below...

How to set background image on the right hand side of a shape in android

android,background,android-edittext,shape
I am making a background shape for EditText - xml below: <?xml version="1.0" encoding="UTF-8" ?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/WhiteSmoke"/> <stroke android:width="1dp" android:color="@color/aadhaar_logo_brown" /> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> <corners android:topRightRadius="10dp" /> <gradient android:startColor="@color/White" android:centerColor="@color/White"...

How to stop the edit text to add text,when the required format text is entered in it? [closed]

android,android-edittext
What is my requirement is when the user enter 10 digits,a Dot and two decimal points(0123456789.00).Once the user entered this format automatically the edit text should stop adding text into it.And the user should not enter more than one dot. is it possible..?.need help thanks in advance..!...

Text cannot be written in multiple lines in EditText

android,layout,android-edittext
EditText has strange behavior. Whatever I write in it is written in only single line. I am not able write text in a second line (new line). Why I cannot write text in multiple lines? Here's my EditText <EditText android:id="@+id/tbr_des" android:layout_width="match_parent" android:layout_height="match_parent" android:hint="@string/des" android:inputType="textCapSentences" android:textColorHint="@color/text_hint" android:textColor="@color/text" android:maxLength="300" android:layout_margin="10dp" android:padding="5dp" android:gravity="start"...

Change layout of EditText on state “selected”

android,android-layout,android-edittext,drawable,android-drawable
I am trying to obtain a EditText changing it's colors and layout when the user clicks on it to type something, and I do that with a custom drawable, but the attributes android:state_enabled="true" android:state_focused="true"> don't work at all, meaning that they don't get called. EditText: <EditText android:id="@+id/field_user_info" android:hint="Nome e Cognome"...

Adding a background image to RelativeLayout hide all others elements

android,background,android-edittext,android-linearlayout,android-relativelayout
I have a simple XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".LoginActivity" android:background="@drawable/login_background"> <LinearLayout android:orientation="vertical" android:layout_width="320dp" android:layout_height="160dp" android:layout_alignParentBottom="true" android:layout_marginStart="218dp"...

Dynamically created EditText's

android,android-edittext,saving-data
I have a Button that creates EditTexts dynamically. I'm not having any problems creating them when I run the app but none of the created EditTexts are being saved when I close the app and reopen it. Here's my code: public class app extends ActionBarActivity { Button add; LinearLayout linearLayout1;...

Setting EditText visibility [duplicate]

java,android,android-edittext,visibility
This question already has an answer here: How to make Views with an Invisible attribute 'Visible' after clicking a button 4 answers I have four EditText that I set to invisible in the XML and when the button is clicked, I want them to be visible in pairs. For...

ScrollView get back to top

android,android-edittext,scrollview,ontouchevent,motionevent
So i have scrollView that has only one view on it (EditText), and i want to implement the dispatchTouchEvent(MotionEvent me) View current_view = Processor.findViewGroupWithPoint( (int) me.getRawX(), (int) me.getRawY(), rmodel.layout.parent); if (current_view instanceof ScrollView) { switch( me.getAction() ){ case MotionEvent.ACTION_DOWN: Log.d(TAG, " down"); ((ScrollView) findViewById(111111)).fullScroll(View.FOCUS_DOWN); break; case MotionEvent.ACTION_UP: Log.d(TAG, " up");...

how to show image when writing on the text

java,android,android-edittext
I want to show an image when the user writing on EditText, here the same output when touching the EditText : menuH.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { menuH2.setVisibility(VISIBLE); return true; } if (event.getAction() == MotionEvent.ACTION_DOWN) { menuH2.setVisibility(View.INVISIBLE); Intent intent = new...

Custom editText on android

android,android-layout,android-edittext,frontend,android-custom-view
I'm newbie with android layout, so i need some help. I want create a custom editText, something like this: I'm want to fix that with the best possible way. Someone? Thanks....

Android Edittext test does not stop at screen boundries

android,android-layout,android-edittext
I added an EditText into a layout for a notepad application. When I tried typing into the EditText I realized that if the text string is longer than the edges of the screen it will just continue past in a straight line instead of going to the next line down....

Android Numeric EditText with multiple Lines

android,android-edittext
I have a numeric EditText and when I try to set multiple lines it doesn't work. This is my code <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="phone" /> Java class EditText editText = (EditText) view.findViewById(R.id.editText); editText.setRawInputType(InputType.TYPE_CLASS_PHONE|InputType.TYPE_TEXT_FLAG_MULTI_LINE); Thanks....

How to change background of TextView From EditText Text Change?

android,colors,background,android-edittext,textview
I am using Fragment class in which I want to change the color of Text View When text is changed on my edit Text. What are the possible ways to change the background color of TextView When Text is Changed in EditText . My code looks like this : public...

how do i check if the edit text view contains 2 white spaces?

android,android-fragments,android-edittext,android-view,android-textview
Currently my edit text view checks if the searched term contains one space as follows: if(mSearchView.getText().toString().contains(" ") How do I make it such that it makes sure it checks if the searchview contains 2 spaces between 3 search terms for example: "here it is"...

TextView and EditText cut off in LinearLayout

android,android-layout,android-edittext,android-view,android-textview
I have a LinearLayout with horizontal orientation in which I add some TextView and EditText dynamically. My problem is when the TextView is long, it is cut off (by height) and the EditText is invisible. Adding padding to the views didn't solve it. When setting the LinearLayout minHeight value, the...

Android comparing String with EditText

android,android-edittext
I'm writing a game which i ask riddles to the player. I've been trying to compare the riddle answer with the input from EditText but I haven't been successful so far. Could anyone help me with that? ib.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String answer = et.getText().toString();...

app crashes with no input while using Edittext in android studio

java,android-studio,android-edittext
I am having this issue with Edittext in android studio.The app works fine but app crashes with no input Here is the java code public void onButtonClick (View v) { int num1,num2,sum; EditText e1 = (EditText)findViewById(R.id.num1); EditText e2 = (EditText)findViewById(R.id.num2); TextView t1 = (TextView)findViewById(R.id.sum); num1 = Integer.parseInt(e1.getText().toString()); num2 = Integer.parseInt(e2.getText().toString());...

How to hide keypad when editText is in focus

android,android-edittext,focus,android-keypad
I want the editText box to be click-able so the user can scroll through the text, but I do not want the keyboard to appear. I have tried all these but they do not do what I want: In XML: android:editable="false" android:windowSoftInputMode="stateAlwaysHidden" android:inputType="none" This disables it: editText.setInputType(EditorInfo.TYPE_NULL); This only works...

Material Design: Button or Edit Text?

android,android-edittext,semantics,android-button,material-design
I have a question about Material Design and semantics. I try to make the settings of my application and I have only a few fields. So I first try to make the UI like this one, with a LinearLayout and some EditText: I have to set hour, and I have...

Add EditText to Toolbar

android,android-edittext,android-custom-view,toolbar
My Toolbar and EditText look like this: I tried adding it as an ActionView but I got this result: It basically just added my words 'Tap Below' as a title without the TextView Here's what I did: menu.xml <menu> ... ... <item android:id="@+id/edit_text_menu" android:orderInCategory="300" android:title="Tap Below" android:actionLayout="@layout/edit_text_layout" app:showAsAction="ifRoom|collapseActionView" /> </menu>...

Design Android EditText to show error message as described by google

android,android-edittext
I need an EditText that looks like this onError: calling onError looks like this instead : Note: the app is running on SDK 19 (4.4.2) min SDK is 1 Is there a method similar to setError that does this automatically, or do I have to write the code for it...

Checkbox enable EditText in RecyclerView issue

android-edittext,recyclerview
I am working for quiz app project. I've got a RecyclerView, each of them contains TextView, two Checkbox and EditText. What I want is when i checked the second Checkbox it will enable the EditText. I have already make this work. but the problem is if I Checked the Checkbox...

How to update TextView with EditText realtime using java Android Studio

android-studio,android-edittext,android-textview
Hey guys and gals I am having trouble figuring out the process and method to best solve my problem.I have an app in which user created text is shown in a secretive font/language, while English(non-secretive) text is displayed in the textview. JAVA import android.graphics.Typeface; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu;...

Show AlertDialog when the property Maxlenght a EditText are exceeded

android,android-edittext,alertdialog
What I want to do now, is to bring up a dialog box, when you exceed the character insertion of EditText, maxlenght set as "15" in the XML file, after which the user can continue to press on the keyboard but to no avail of course, and I would then...

How to retain the hint text in android EditText field?

android,android-layout,android-edittext
In my android app, I have a hint text in my EditText view. Once the user starts typing, I want the hint to be displayed on top of the edittext field. The original hint text disappears when user starts typing which is fine. How do I place a text on...

How to store all json object values in arraylist?

android,json,android-edittext,jsonobject
I have following response...from this response i am parsing bulkprice array and its objects,now what I am trying is that I need to store all the minqty values in one arraylist and want to convert all those values in Integer..but I am not able to get that.. {"status":"success","clientproduct":[{"pid":"4","name":"kangan pair","unitprice":"1500","boxqty":"1","bulkprice":[{"minqty":"10","price":"1500"},{"minqty":"15","price":"1470"},{"minqty":"20","price":"1460"}]}]} MainActivity.java...

Edittext Keyboard Not Showing After First Input

android,android-edittext
So I need an input box for text in my android app. I have this in my xml: <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/inputCodePA" android:textSize="18sp" android:inputType="text" android:hint="@string/inputHint" android:layout_alignParentBottom="true" android:layout_toRightOf="@+id/arrowRightPA" android:layout_toEndOf="@+id/arrowRightPA"> <requestFocus/> </EditText> and this: public void setOnClickListners(){ final EditText inputBox =...

Getting strings from `Edittext` thats valid

android,android-edittext,textview
I have 5 Edittexts and a TextView at the end of them to calculate the average of the data in the EditTexts. How can I only divide by the number of EditTexts that only has input in it? Right now I'm dividing by the num of total EditTexts, which is...

how to start contextual action bar for text view programatically with default opions copy and select all?

android,android-actionbar,android-edittext,android-textview,contextual-action-bar
Is there any way to programatically start contextual action bar associated with a text view, on a button click? It should contain default options of copy/select all as well. Basically, I want to show the selection handles in my text view and the android default copy/select all option in action...

Incompatible types: android.widget.Edit Text and java.lang.String

android,android-edittext
I have got this error on Android Studio IDE. It says Incompatible types; Required android.widget.EditText and Found java.lang.String @Override public void afterTextChanged(Editable s) { if (editabletext.length() == 8) { editabletext = editabletext.getText().toString().replaceAll("([0-9]{4})([0-9]{4})", "$1-$2") } } ...

how to change the background color of TextView if EditText is empty in android?

android,background,android-edittext,textview,textchanged
I am using Fragment class in which I want to change the color of TextView When EditText is empty after text is changed. I am able to change the color of TextView on text change but when the text is clear the TextView background color doesnot change to previous one....

How to check for initial spaces in the text entered in edit text android

android,validation,android-edittext
I have an issue in validating edit text in my android application. I have tried many methods and none of them are suiting my scenario. When user tries to save the post the entering only spaces in edit text field I need to pop out an error message. But I...

EditText remove focus if setText()

android,android-edittext
I have an EditText that as an textChangedListener When I use myEditText.setText("") two things happen: The keyboard pops up The texChangedListener (TextWatcher) is fired. I want to know if there is a way of removing any related events when we use setText() The first problem I've solved with if (getWindow()...

How to enter 4 numbers in EditText and seprate it as four variables in code ? Android beginner

android,android-edittext
Hi I just started android development, And I want to know how I can separate the 4 numbers I enter in a single edittext in order as four variables ? Since I'm a noob your help means a lot for my training. I want to put it in a array...

EditText: suppress soft keyboard but allow selection and cursor?

android,android-edittext,android-softkeyboard
I want to display an EditText which will be edited mostly by selecting parts of it and pressing buttons to insert new values. (The values are long hex strings which I don't want the user to have to type.) Therefore, I want to suppress the display of the soft keyboard...

Android Edit Text - Input Type Number not setting max value

java,android,android-edittext,numbers,android-inputtype
So what I would like is a very simple edit text with input type number or decimal that has the following aspects. Number Edit Text: You can only type up to Long.MAX_VALUE / Long.MIN_VALUE, so I can cast to a long without modifying the user's input. Number Decimal Edit Text:...

How add another EditText when I click and fill another ( Android ) [closed]

java,android,user-interface,android-edittext
I was googling for a while but I can't find the way how to add a another EditText after I click on one. I try to describe my problem by this picture: Is there a some container providing this functionality ?...

How can I use edittext value in for loop?

string,for-loop,android-edittext,integer
Even though I convert the value from string to Integer it throws an error as java.lang.NumberFormatException: Invalid int: "" ...

I can't input the obelus(division symbol) in edittext android

android,input,android-edittext
The title says it all. I am trying to make a calculator and of course, a calculator has a division symbol. The text of the button in the XML file can be changed to an obelus but pressing the button can't input the symbol in the Edittext. Instead, a diamond...

android - enter multiple string values to edittext

android,android-edittext,autocompletetextview
I have an app in android that handles reporting about classes taken. I have a edittext that is for entering the teacher's name, but there is a possibilty that there are more then one teacher. I want to put all the names in the same edittext, similar to how its...

Enter character immediately after entering first character in android

java,android,string,android-edittext
I am having a editText and inputType as phone number. I would like add specific area code immediately after I enter first digit. Say for example I enter 6 the EditText should show up +1 6. I am trying achieve this using textWatcher but not sure how to put the...

Android ListView adding too many items

android,for-loop,android-listview,android-edittext,android-linearlayout
I am currently adding TextViews inside a LinearLayout inside a ListView element using a for loop, because the amount of TextViews I have to add in there is variable. I am adding the items to the ListViews like you normally do. The problem is, when I scroll the items start...

How to handle addTextChangedListener on two EditText together?

android,layout,android-edittext,actionlistener
Reququirement : There are two EditText one is Username and another is Password. I am checking on both EditText has more than one character than button of Signup should enable. Can anyone pls suggest me ? etUsername.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count)...

How to prevent deleting the first character of edit text in Android

android,android-edittext,substring,android-textview
This is one of my Edit text in the application <EditText android:id="@+id/etFolder" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="/pictures" android:ems="10" > When it appear at first time it comes with "/pictures" User can change the text and enter another word. but how to prevent deleting "/" of Edit text. user can delete all other...

How to get the currently typed text from edittext using textwatcher?

java,android,android-edittext
For example: if I typed "hello sir", then how can I get "hello" as soon as I tapped space bar before I start typing "sir" using textwatcher in android. I need currently typed single text from edittext as soon as user hit the space bar not all the string from...

android: List view edittext data loses on scrolling

android,listview,android-edittext
I went through almost all the similar questions and tried what was suggested (didnt understand much). I want the listview having 2 edittexts to preserve the values even after becoming invisible after scrolling. And when the edittext losses focus, i want each edittext value to be saved in a arraylist...

Android EditText setHint's font size dynamically

android,android-edittext,font-size,dynamically-generated
I've been struggling with setting size of hints in my EditText. The hint's font size becomes too large and the layout starts to look horrible! EditText dummy = new EditText(); dummy.setHint("some hint"); How do I dynamically and programmatically change the hint's font size w.r.t my priorly set MAX_HINT_SIZE (in pixels)?...

What is default value for edittext field

android,ide,android-edittext
In android studio it is saying that private field principal and interest is never assigned, does anyone know what the default values are so I can assign them? private EditText principal; private EditText interest; ...

How to make a Custom View(EditText) on the actionbar automatically selected?

android,xml,android-actionbar,android-edittext
Currently I am making an app that has an EditText on the action bar. I found out how to put a custom view on an actionbar from the following link: How to set a custom view in actionbar in android?. I used the getSupportActionBar to load an EditText onto the...

Bad cursor color on custom edittext

android,android-edittext,autocompletetextview
I tried to override the AutoCompleteTextView and the cursor in the field is now white. Because of bright gray background it is difficult to recognize them. I don't understand how it could be possible, I didn't set any custom style, the other fields are ok and show standart green cursor....

how to display number in textview(activity2) from edittext(activity1) ? Say example phone number

android,eclipse,android-edittext,textview
Activity 1: public class Start extends ActionBarActivity { EditText MobileNo; EditText Name; Button Next; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); Next = (Button)findViewById(R.id.Next); Next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub MobileNo = (EditText)findViewById(R.id.MobileNumber); int Data = Integer.parseInt(MobileNo.getText().toString()); Name =...