Tag: android-edittext

Create a multiline EditText programatically

I am trying to create a multiline EditText by code. This is what I use: EditText txt = new EditText(this); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); txt.setLayoutParams(lp); txt.setSingleLine(false); txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); But it is still in one single line. Any help?

How to enter a “Negative Decimal Number” in EditText?

I am making a calculator and I want to make sure that user is able to enter a “Negative Decimal Number” I see the option in the xml file separately for example in order to put the Decimal Number, the EditText’s inputType must be numberDecimal and for negative number the inputType must be “numberSigned” but […]

How to change EditText content with Javascript?

We have a button in HTML. When the user clicks it, the value of my specific EditText should change, but it doesn’t. Code: class ActivityTest extends Activity { TextView textView1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test); WebView webView = (WebView) findViewById(R.id.webView); webView.loadUrl(“file:///android_res/raw/htmlimages.html”); webView.addJavascriptInterface(new MyTest(), “Scripts”); webView.getSettings().setJavaScriptEnabled(true); textView1 = (TextView) findViewById(R.id.textView1); } public class […]

Text align problem when using Arabic font

The screenshot below displays my problem. The first EditText shows a hint in Arabic which is shifted upwards, now the second EditText is just for reference which shows the English version completely fine. Same goes for the Button. I have declared the string in strings.xml like this: <string name=”ar_login”>دخول</string> This is how I set the […]

How to customize the “chips” auto-suggesting mechanism, as used on Gmail's recipients field?

Background I’ve searched for a way to have a similar look & feel to the Gmail receipients field, which allows auto-filling of items in a really cool way: The class that is built into the Android framework and is responsible for this is called “MultiAutoCompleteTextView” . The problem the MultiAutoCompleteTextView is quite basic, yet it […]

Stop EditText from gaining focus at Activity startup

I have an Android Activity, with two elements: EditText ListView When my Activity starts, the EditText immediately has input focus (flashing cursor). I don’t want any control to have input focus at startup. I tried: EditText.setSelected(false); No luck. How can I convince the EditText to not select itself when the Activity starts?

Android 6 EditText.setError not working correctly

I have upgraded to android 6 and seeing some strange things when trying to set validation for some editTexts. I am using android-saripaar for validation: @Email(messageResId = R.string.error_email) private EditText email; @Password(min = 6, scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS) private EditText password; @ConfirmPassword private EditText repassword; @NotEmpty(messageResId = R.string.error_name) private EditText firstname; @NotEmpty(messageResId = R.string.error_name) private EditText […]

Detect delete button in soft keyboard

I have two EditText (each only only accepts one character) and I want to handle both fields like I had only one. I’m using a TextWatcher to set the focus in the second one when the user writes a character in the first one, but I don’t know how to do the opposite. If the […]

Why EditText in a custom compound view is re-using the text entered in another compound view instance?

I’m trying to write a custom compound view composed by a TextView and an EditText, _compound_view.xml_: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/compoundText” android:layout_width=”match_parent” android:layout_height=”wrap_content” > <TextView android:id=”@+id/textLabel” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Label” /> <EditText android:id=”@+id/textEdit” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:hint=”enter text here” > </EditText> and this is the class extending LinearLayout: public class CompoundView extends LinearLayout { public CompoundView(Context context, AttributeSet attrs) […]

Android: Error popup on EditText doesn't move down when keyboard goes away

I have an activity that displays a few EditTexts on screen for user input. To be sure the soft keyboard doesn’t cover my fields when it displays I have set the property android:windowSoftInputMode=”adjustPan” for my Activity in the manifest. I am validating the EditText’s content when 1. The view loses focus 2. When the user […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.