problem with linkify in android app - android

I have a phone number in a text view (thats the only thing I have there). I am using :
Linkify.addLinks(textView, Linkify.ALL);
However, the phone number is not being recognized by linkify. The number is of the format:
(123) 456-7890. I have also tried 1234567890 and 123.456.7890. Nothing works. Any help ?
thanks.

In your XML file of your Text View add an attribute android:phoneNumber="true"
Try this in the Click of the Text View :
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("tel:"
+ your_phone_number)));
Automatically the Text will have the property of Phone number.

Since you are trying something that is custom refer to this doc
http://developer.android.com/resources/articles/wikinotes-linkify.html
it will help you.

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);

How to auto fill an edit text in android application?

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"

How to change color of a text using HTML tag in Android

I have a string which contain three words. I want to show the three words in same textview but in different line. For this I have used <br> tag. Now I want to show the last word in red color. I tried so many codes but nothing worked for me.
My code snippet is
viewHolder.cutomerinfo.setText(
customerDetail[0]+Html.fromHtml("<br>")+
customerDetail[1]+Html.fromHtml("<br>")+
Html.fromHtml("<font color='#ff0000'>")+
customerDetail[2]+Html.fromHtml("</font>"));
Do like that:
code:
String toshowstring = customerDetail[0]+customerDetail[1]+
"<font color='red'>"+customerDetail[2]+"</font>";
viewHolder.cutomerinfo.setText(Html.fromHtml(toshowstring));
That's all you want.
^-^
//only one Html.fromHtml() method is enough
viewHolder.cutomerinfo.setText(
customerDetail[0]+Html.fromHtml("<br>"+customerDetail[1]+
"<br><font color='#ff0000'>"+
customerDetail[2]+"</font>"));
for Ref:

Arabic Text displaying Problems

I am getting the problem while displaying arabic text in my android device
the require text is shown below
i am getting the different text like this
I am using the following code for this
my text is this :
category_arabic[3] = "محـامـون" ;
Typeface tfarsi1 = Farsi.GetFarsiFont(this);
((TextView) pageView
.findViewById(R.id.menu_txtAttorneyLegalServices_ar))
.setTypeface(tfarsi1 );
((TextView) pageView
.findViewById(R.id.menu_txtAutoRepairSmog_ar))
.setText(Farsi.Convert(category_arabic[3]));
Please give me some solution for this problem. what i have to do for this ? i also used the ArabicUtilities.java file for this solution but not get the proper solution
you can use ArabicUtilities.java and reshape your text with "reshaper" function. for example:
textView1.setText(ArabicUtilities.reshape("نمايش"));

Android TextView enable LinkiFy and Href tags

I want to set a text to the textview which contains href tags as well as normal http links. For ex, text like this "please <a href=/'http://google.com' target='_blank'>click here</a>. or visit http://yahoo.com".
The issue is I am unable to set both properties together. If I set Html.fromHtml to the text, the link with the href tag is highlighted. But the Linkfy property is not working for "http://yahoo.com" and vice versa. Is there any default property to enable both href tags and normal links in a TextView.
Thanks,
I couldn't find one myself as I worked through a similar situation with HREFs and telephone numbers; in lieu of anything better, I am currently using a custom REGEX for calling Linkfiy.addLinks. Calling Linkify.addLinks with a mask "also removes any existing URLSpans attached to the Spannable", which were created by Html.fromHtml. See the Linkify Documentation.
If it's possible using an mx controls Label (spark does not support this any longer) u can use htmlText like the following example:
import mx.controls.Label //class need to be imported
var textview:Label = new Label();
textview.htmlText = "please <a href=/'http://google.com' target='_blank'>click here</a>. or visit http://yahoo.com";
yourItemContainer.addElement(textview);
This should work. But I don't know if it's possible for u using a normal label.

Categories

Resources