I would like a setting in preferences that allows the user to create a password. The perfect example is in the Play Store. In settings you click on Password and a dialog box pops up with an EditText field with a password field that hides the characters. How would you do that?
I'm pretty sure this is not EditTextPreference. Is this a custom preference? How would you make this? Can I get a sample for the XML part of it?
I'm pretty sure this is not EditText preference
EditTextPreference would work. Quoting the documentation:
This EditText can be modified either programmatically via getEditText(), or through XML by setting any EditText attributes on the EditTextPreference.
So adding android:password="true" as part of your preference XML should work.
That being said, you are certainly welcome to create your own custom DialogPreference for this.
Using intents
In some cases, you might want a preference item to open a different activity instead of a settings screen, such as a web browser to view a web page. To invoke an Intent when the user selects a preference item
it's available at android guide, check this link
http://developer.android.com/guide/topics/ui/settings.html#Intents
Related
I checked different options that are available in PreferenceScreen (eg. CheckBoxPreference, EditTextPreference, etc.) but non of them give me the possiblity to obtain a simple dialog with just 2 buttons. I would like to use it to implement a basic “Yes, reset my app” / “Cancel” features. How to make this preference option easily?
Its tricky check this answer.
Well I've implemented EditText Preference which shows 2 buttons ok and cancel but in middle there is Edittext.
I have a preference page where there is a check box preference for enable login password. When the user check it, it should have a dialog pop out and inside there will be 2 edit text fields for password.
I have done some readings and it seems like using a custom dialog will be the right choice. But the problem is that there is no onCreateDialog() method for the preference activity to override, how do I solve this problem?
Some example codes will be nice. Thanks!
Create your own custom subclass of DialogPreference that handles your dialog and persists your preference value, and use that in your preference XML resource.
I am writing an application in which I need to restrict EditText to accept URLs only. How can this be done in Android?
Open the Properties of your EditBox. Property InputType offers you a list of checkboxes, and one of them is textUri.
It is also working with EditTextPreference although is not shown as property.
I was trying to make my UI as neat as possible,
The user should enter some values into a circuit diagram,so I was trying to make the user click the resistor for example, then, a pop-up window appear with an EditText field in it for the user to enter the value of the resistor.
So far I was able to do that by using two separate setContentView()s, one for the circuit diagram and the other holds the EditText field, but I want the layout with the circuit Diagram to be visible in the background while the pop-up is the one in focus.
something like this (random example from the web):
http://blog.itechtalk.com/wp-content/2010/10/SMS-Popup-1.png
You are looking for a dialog. See creating dialogs.
Actually smsmpopup uses an activity with theme dialog in it's manifest. Check the src code.
yes.. u want something as a Dialog... but if its an activity.. u can set this paramenter in the androidmanifest file..
android:name=".Pick_Color"
android:label="Pick a Color !"
android:theme="#android:style/Theme.Dialog">
this will make the screen as neat and Dialogish as possible
I am using preferences, and this snippet of XML always causes my application to stop unexpectly when I hit a menu settings button which is supposed to display a list of preferences. I can use CheckBoxPreference and ListPreference successfully but I cannot use DialogPreference. I cannot seem to find an example XML snippet anywhere.
I need this dialog to collect a phone number in a string.
I should have been using EditTextPreference which extends DialogPreference. This works.