I am trying to do agent training using api.ai.
I wanted to read a secret key from user expression. Is it possible to allow the user text entry in secured format (Like we enter passwords - the big black dots)?
You can use an EditText with the inputType set to textPassword like this:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
Related
Modifying an APK to try to make something slightly more user friendly. There is a login screen with username and password and a server portal field. The portal field now never needs to change. So I want to set a default text so the user does not have to type in the full portal URL
Currently looks like this
<EditText android:textSize="15.0dip"
android:textColor="#color/black"
android:textColorHint="#color/white"
android:id="#id/et_sever_url"
android:background="#drawable/selector_login_fields"
android:paddingLeft="20.0dip"
android:paddingRight="20.0dip"
android:focusable="true"
android:nextFocusUp="#id/et_password"
android:nextFocusDown="#id/bt_submit"
android:layout_width="fill_parent"
android:layout_height="50.0dip"
android:layout_marginLeft="25.0dip"
android:layout_marginTop="20.0dip"
android:layout_marginRight="25.0dip"
android:text="#string/serverurl"
android:hint="#string/serverurl"
android:maxLines="1" android:lines="1"
android:layout_below="#id/et_password"
android:layout_centerHorizontal="true"
android:inputType="textUri"
android:textCursorDrawable="#null"
android:fontFamily="sans-serif" />
The text and the hint just put the server url in the field but it still has to be manually typed in. I tried to use android:setText="#string/serverurl" but then the apk fails to compile again.
There is no edittext properties like this : android:setText="#string/serverurl"
All you want to do set default string to your editext then in xml just use below property.
android:text="#string/serverurl"
Also remove the hint property you really don't need that because you are seting default text so hint won't be shown.
Also second why to do this in java code like below.
EditText edtServerUrl =findViewById(R.id.et_sever_url);
edtServerUrl.setText(R.string.serverurl)
Put above code inside onCreate() method of activity.
I have an application that requires that the user enter an ASCII password between dec 32 and 126. This means that only a latin character and number keyboard is valid for editing. However, when I launch my edittext, a cyrillic keyboard is presented to the user.
My question is, how do I ensure that only a latin keyboard is presented to the user?
Try to add this to your xml:
<EditText
android:inputType="text"
android:digits="0,1,2,3,4,5,6,7,8,9,*,qwertzuiopasdfghjklyxcvbnm" />
There is no way to force IME to a certain language/character set. However, if you set your EditText to be type password, most software keyboards will limit itself to ASCII + number. That's the closest you will get without writing your own input method.
<EditText
android:password="true"
...
/>
I have an EditText like this:
<EditText
android:id="#+id/txt_login_username"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_above="#+id/pengala_logo"
android:layout_alignLeft="#+id/txt_login_pwd"
android:ems="10"
android:hint="Please enter Email"
android:inputType="textAutoComplete"
android:textColorHint="#ffffff"
android:textSize="20sp" />
I want to show all email ids as suggestion when a user starts typing in the EditText. Similar to this
For that use Autocomplete TextView.
When user enter userName in Autocomplete TextView and press login you need to store username in sharedpreferences. For sharedpreferences see This tutorial.
Select entred values from sharedpreferences and display it in your Autocomplete TextView when user comes again.
Use this library for achieving this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<jp.yokomark.widget.account.autocomp.AccountAutoCompleteEditText
android:id="#+id/any"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/label_account_type_any"
app:accountType="any"/>
AccountAutoCompleteEditText has a custom attribute of accountType. This attribute accepts any of the following value.
Value Meaning
any Show the candidate account of all type.
email Show the candidate account using email address.
phoneNumber Show the candidate account using phone number.
By this you can easily use it
Is there any way to limit users allowed to type only some selected character set (Eg: A or B or C or D) in Android layout.xml
Use the digits attribute, only the characters passed to digits will be allowed in the EditText.
android:digits="abc123"
And yes, "digits" is a misleading name, it accepts letters and symbols too.
You can use the inputType attribute:
<EditText android:id="#+id/edit_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number" />
Possible Values for android:inputType attribute in edit text are: none, text, textCapCharacters, textCapWords, textCapSentences, textAutoCorrect, textAutoComplete, textMultiLine, textImeMultiLine, textNoSuggestions, textUri, textEmailAddress, textEmailSubject, textShortMessage, textLongMessage, textPersonName, textPostalAddress, textPassword, textVisiblePassword, textWebEditText, textFilter, textPhonetic, textWebEmailAddress, textWebPassword, number, numberSigned, numberDecimal, numberPassword, phone, datetime, date, time
This android:digit will allow only the digits and alphabets you want to be filled in EditText.
<EditText
android:inputType="text"
android:digits="0123456789*qwertzuiopasdfghjklyxcvbnm,_,-"
android:hint="Only letters, digits, _ and - allowed"
/>
You can set your EditText Field like this...
<EditText
android:inputType="text"
android:digits="THE SELECTED CHARACTERS THAT USERS ARE ALLOWED TO TYPE"
/>
By listing the selected characters (A,B,C,and D) that users are allowed to type in the android:digits, you are limiting the possible characters that users can type. This is the easiest way I've learned through searching.
Hi in my project i have a edit text box, where i want the user to enter his phone number, I need it in a format like +0000000000 no need to allow - or any other symbols. I need to restrict the user while entering in keyboard. I have implemented the regular expression for validation for this format and I am using android:inputType="phone" is there any other input Type is available or can i customize it in any way. Looking for help pls...
Try it android:digits="+0123456789"
try this::
android:inputType="number"
it allow user to enter only integer value