How to auto fill an edit text in android application? - android

I am developing one android application. In which I have some Products and form to purchase that product. In the Order form I have one Edit Text as Product ( means product name) .
In my application user has to type Product name but I want to know that Is there any way that
the EditText field is autofilled with that particular Product like as in flipcart.
Any one knows then suggest me...
Thanks in advance...

When you want to populate it just call (after reading it in from the XML layout in this example):
EditText myTextBox = (EditText) findViewById(R.id.editBox);
myTextBox.setText("My Product Description");
If what you are looking for is an auto completion after they have started typing, then an AutoCompleteTextView is your best bet, replacing the EditText and providing the auto complete functionality
There is an example of this over at the Android Developers website:
http://developer.android.com/guide/topics/ui/controls/text.html#AutoComplete

you can use autocomplete textview for suggestion of your all the product names, refer this example http://saigeethamn.blogspot.in/2010/05/auto-complete-text-view-android.html
or you just want to show when app launches, use hint
android:hint="#string/enterproduct"

I Dont get u clearly..
Sooo.
If u want to show text that which user has to fill use Hint.
android:hint="Enter any Filpcart Item"
OR
If u need auto complete text then use above link #kumaand.

Here you can use "input type" in XML design according to the text field.

Add into the XML file
android:autofillHints="emailAddress"
or
android:autofillHints="password"

Related

Preview text in Android

I'm working on a application project as my bachelor thesis and I wonder if it's possible to set a text in a Edittext box?
I'm not talking about the editText.setHint("My text"), or android:hint in the XML. I want to fetch a variable from a Web Service (This variable may change depend on what you do ).
For example. You have a shoppinglist. The list says "Go buy two pieces of bread ", and the editText Box is supposed to have " 2 " in the box (so you can directly proceed from there) but if you didn't buy two pieces of bread, you can edit it to " 1 ".
It's hard to explain this, but I hope you guys understands. If not, let me know and I'll try to explain again.
Thanks in advanced!
Just use
EditText editText = (EditText)findViewById(R.id.edit_text_id);
editText.setText("1");
simple:
EditText editText = (EditText)findViewById(R.id.your_edit_text_id);
editText.setText("1", TextView.BufferType.EDITABLE);

android edittext limit to text and numbers

I am creating an android application. The first thing I'm creating is a login activity. I am trying to limit the username edittext just to text/numbers only (no special characters). Is there a way to adjust this in the xml file?
I dont think you can limit the characters from xml. You could always use a InputFilter, but specifically android provides UsernameFilterGeneric to filter valid user names. You could also use UsernameFilterGMail
As you already use in java Regular expression.called the same class here for checking for particular field.
let me know if you want some more if you didn't know about the RE.

Android xml phone number in keyboard restriction

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

TextView to send email when clicked

I have a TextView with android:autoLink="email".
If I put my email address in there then a link appears that I can click.
How do I have different text appear (for example 'Send Feedback') instead of the email address but still behave the same when clicked?
Thanks
To achieve what I wanted required a different approach:
TextView feedback = (TextView) findViewById(R.id.TextViewSendFeedback);
feedback.setText(Html.fromHtml("Send Feedback"));
feedback.setMovementMethod(LinkMovementMethod.getInstance());
This basically places HTML in the TextView so I get a link saying 'Send Feedback' but clicking it opens the default email application.
Word of warning: Trying this in the emulator didn't initially work for me, saying it was unsupported. This was just because I didn't have an email account setup. Setting one up in the emulator made the link work as I wanted.
You can use both links and email if you set the following param in the TextView
android:autoLink="web|email"
the links will be opened in the browser and the mails will be sent by the default mail client
Another simple way in layout:
...
<TextView
android:id="#+id/tvTelefone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sobre_telefone"
android:textColor="#000000"
android:autoLink="phone" />
...
...
<string name="sobre_telefone">Contato: (45) 9145-0000</string>
}
Read more here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink
It might be easier to create a button and inside your onClickListener() pull an email from maybe R.string.email.
Fro the Strings From strings.xml :
<string name="your_string"><![CDATA[ contact us at recipient#mail.com for more help.]]></string>
tvObject.setText(Html.fromHtml(getString(R.string.your_string)));
tvObject.setMovementMethod(LinkMovementMethod.getInstance());

How to setup my EditText xml in Android

For allow user only can input lower case alphabet and number, how can I setup my EditText in a xml file ?
Sorry, I did not provide clear information. I just want to filter or check user's input.
AFAIK, your question is complicated to do. better get a input from user. then you can convert that string to lowercase using toLowerCase().

Categories

Resources