Edittext set for password with phone number input? (android)
How do I get a Edittext with both a phone input and the ability to hide the string. I know that
android:inputType="textPassword"
hides the string, while
android:inputType="phone"
brings up a dialpad interface.
How to combine the two?
Asked by: Andrew845 | Posted: 25-01-2022
Answer 1
android:password
is deprecated, but AFAIK is the only way because android:inputType="phone|textPassword"
is ignored ...
<EditText
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:password="true"
android:inputType="phone" />
Answered by: Joyce860 | Posted: 26-02-2022
Answer 2
I believe this is what you want?
android:inputType="numberPassword"
Edit: At the time of the question (2010) this may have not been in the API, but for contemporary development, it's available.
Answered by: Julian825 | Posted: 26-02-2022Answer 3
I have not found an appropriate solution to this problem. dtmilano's accepted solution doesn't fully work. If the EditText is focused in landscape mode where you have the full screen keyboard, the numbers still display in clear text, not masked.
I spent significant time going through the actual TextView code, and the reason this is a problem is that they are explicitly checking the InputType against InputType.TYPE_CLASS_TEXT and, if I recall correctly, TYPE_MASK_CLASS. So if you include any other InputType within those bounds (I think the range used by TYPE_CLASS_TEXT and TYPE_MASK_CLASS is the first byte), then it won't be recognized as a password that needs masking.
I know what I said is pretty confusing. The actual code is a LOT more confusing. I was pretty appalled at the TextView's code to be honest. It's a tangled mess, with hard coded checks everywhere. Horrible coding practice which leads to problems like this.
Answered by: Roman810 | Posted: 26-02-2022Answer 4
This problem can be solved without using deprecated android:password
. See my answer here.
Answer 5
I haven't tried this, but it might be possible to combine the two like so:
android:inputType="textPassword|phone"
since inputType
can take on multiple values.
Similar questions
java - Drawing Nine Patch onto Canvas (Android)
I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch.
Why isn't this simpler? What is the "chunk"? And if you have done this yourself, how did you go about it?
Any help appreciated.
storage - Why is my SD Card not writable (Android)?
In the emulator I can't seem to write to the attached SDCard. The following code always spits out the "can't write root" log message, but not the "can't read root" one.
File routesRoot = Environment.getExternalStorageDirectory();
if (!routesRoot.canWrite())
Log.v(getClass().getSimpleName(), "can't write root");
if (!routesRoot.canRead())
Log.v(getClass().getSimpleName(), "can't read root");
listview - How do I display 2 views in 1 activity (android)?
Suppose I have a webview open:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
main_webv = (WebView) findViewById(R.id.mainwebview);
main_webv.setWebViewClient(new HelloWebViewClient());
main_webv.getSettings().setJavaScriptEnabled(true);
main_webv.getSettings().setSupportZoom(false);
main_webv.addJavascriptIn...
(Android) How to catch a "ring" event?
I'm clearly a newb, and I was wondering if anyone knows how I can detect a "ring" event on my cellphone through the android sdk? Generally I want to do something with the phone when it begins ringing! Any thoughts?
If you want to simply point me to a page in the api documents that would be a good answer for me, I just don't know how to start my research!
Quick check on use of map api (android)
When you use the Google map api, it is not part of the Android SDK, and you have to mention it in your manifest xml file.
Do you have to do anything to access the jar file containing the map api code? Or is that automatically present on the device or emulator, the way the SDK code is?
Do you need put the map api jar file in your class path, either when compiling or when executing? Or is it kept somewhere ...
java - How do I use the session in WebView in my other stuff (Android)?
The user must login through the WebView. Of course, the session is for that WebView.
But, what if I need to make REST API calls during my Android application?
Those REST API calls need the session to be authenticated , otherwise those will not work. Is there any way I can attach the cookies of WebView into everything I do in Android?
java - Getting a variable out of a Public Void (Android)
I have this code:
hubSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
final MediaPlayer mp2 = MediaPlayer.create(Textbox.this, R.raw.hero);
mp2.start();
}
public void onNothingSelected(AdapterView<?> parentView) {
}
});
java - Stopping and Play button for Audio (Android)
I have this problem, I have some audio I wish to play...
And I have two buttons for it, 'Play' and 'Stop'...
Problem is, after I press the stop button, and then press the Play button, nothing happens. -The stop button stops the song, but I want the Play button to play the song again (from the start) Here is my code:
final MediaPlayer mp = MediaPlayer.create(this, R.raw.megadeth);
Shader as a drawable (Android)
How do I use obtain a drawable from a Shader (such as LinearGradient) so that I can use it as a background in my UI?
Get text from listview onclick (Android)
I am creating lists in my android app and would like to capture the text of the list item that is clicked but I want to do it in a seperate function so I only have to write the code once. And I want to be able to compare the string to another sting.
What is the best way to do this?
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android