I got this situation that i have to find * and replace with editable text for example: "HI *, What your order * some text. some more text * after". Now i need output like this Hi ____, What your order ____ some text. some more text ___ after how can i achieve this in Android please help thanks.
Firstly Spit the strings by using this post :-
How to split a string in Java
And then add edittext after each string to show output like yours.
This is Easy dude!
Just store your template in Preference, then take values from user and show it back to user with template.
For example; i Stored following in Preference:
I used specific keywords here to differentiate user's response:
Hi (name), What your order (order) some text. some more text (other)
after
where (name) is for user's name;
(order) is for user's order; and
(other) is for other info.
Now, take input from User by some Input field form, and use preference like this.
String mTemplate = "Hi (name), What your order (order) some text. some
more text (other) after";
Replace keywords with user's response like this;
mTemplate.replace("(name)","UserName_goes_here").replace("(order)","UserOrder_goes_here").replace("(other)","OtherInfo_goes_here");
Here, you'll get strings with your template. Hope this helps you.
Related
How do I set the input type for registration number. For example my university has specific format for registration number i.e. CIIT/SP17-mcs-044/Atk. I want CIIT/ATK is written already and Sp17-mcs-044 as a hint.
You can't define a random types of input type. You can only have one of these types as inputType.
If you want any custom behaviour, you might use TextWatcher and validate it
As #Tim has stated, the input type would be text over here and when user types in that EditText then check if the input is correct by using RegEx, and then show any message when the input is correct, for that you will need to add an OnTextChangedListener, about which you can learn more on official documentation.
Now, CIIT/ATK can be a TextView placed right before the EditText so it will be written already and will be uneditable. And yes, add that in final string after getting the input, like this:
finalInput = "CIIT/ATK" + input;
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"
can any one know about how to add/insert emotions/smiles to text(which ever i typed in my edit text for my notes). i have little confusion about if i want to add these smiles of type .png in to edit text type of string, is it possible? and also i have to save these input into sqlite database. normally i know to store string data taken from edit text.
but along with that text i want to also add smiles symbols where ever my cursor placed and to be store in sqlite data base. and get it back to read.
so guys any ideas, most welcome!
Try to use java (i.e. android) spannable method to implement smiley (i.e.) images for that. You will surely get it, search in google for "how to add images/smiley with java spannable method in android?" you will get good idea.
Reading your question the first thing I can think of is Mapping each image to a sequence of letters, for example :) is smiley.png etc. Now your database also has these smaller representation However while reading from the database you can convert those special character sequences to appropriate image.
For simplicity in seraching those Strings You can wrap them in some less used characters i.e. [ or { or <.
Friend's
I'm working upon searching in maps, here i have string in my array,when i enter characters for searching in Edit text box,i need the string have started with similar character in my result.
for example in my array i have String[] name ={"A","B","BB","Boys","Box"}
Initially i have all the array string in my result,if i suppose enter an character like b in editbox i need filter and show the charcters matches with b that is "B","BB",""Boys","Box",if suppose i enter two characters like "bo"in editbox ,i need result strings "Boys","Box"in another array.
Help me.
thanks in advance.
Consider using AutoCompleteTextView instead of simple EditText.
I've searched high and low for something that seems to be a simple task. Forgive me, I am coming to Android from other programming languages and am new to this platform and Java.
What I want to do is create a dialog pop-up where a user enters text to search for and the code would take that text and search for it within all the text in an EditText control and if it's found, highlight it.
I've done this before, for example in VB and it went something similar to this pseudo code:
grab the text from the (EditText) assign it to a string
search the length of that string (character by character) for the substring, if it's found return the position (index) of the substring within the string.
if found, start the (EditText).setSelection highlight beginning on the returned position for the length of
Does this make sense?
I just want to search a EditText for and when found, scroll to it and it'll be highlighted. Maybe there's something in Android/Java equivalent to what I need here?
Any help / pointers would be greatly appreciated
grab the text from the (EditText) assign it to a string
Try the code sample below:
EditText inputUsername = (EditText) findViewById(R.id.manageAccountInputUsername);
inputUsername.getText().toString()
^^ Replace the IDs with the IDs you are using.
After this, you have the standard string methods available. You could also use Regex for a complex search query:
http://developer.android.com/reference/java/lang/String.html
http://developer.android.com/reference/java/util/regex/package-summary.html