I am trying to achieve a functionality where user can click a part of a text such as the username or a hashtag in a string which is used by most social apps.
There doesn't seem to be a way as of now.
Any help will be most appreciated.
Ti SDK 5.2.2
Android
Try to use an AttributedString. It allows you to display "html" like text. There is an easy to use module: https://github.com/FokkeZB/ti-html2as where you can set HTML text and it will convert it to an AttributedString.
So you would use a regular expression to convert you clickable elements (e.g. #element -> #element) and check for the click response
Related
Generally, I'm trying to save some text from edittext in android studio to string and than later write it to pdf using pdf stamper and send it via e-mail. I'm using default encoding UTF-8 because I cannot (or don't know) to change it since it's hard-coded. User will eventually enter some of these characters. What is the best way to make this characters visible or to prevent user from typing those characters?
Thanks :)
Use special characters and set it to text view like how u set & :- &
or use Html within TextView :-
#For example (< Android Nougat):
myTextView.setText(Html.fromHtml("č"));
#For example (>= Android Nougat):
myTextView.setText(Html.fromHtml("č", Html.FROM_HTML_MODE_COMPACT));
try this,
myTextView.setText(Html.fromHtml("č"));
You can save it to xml as
<string name="random">" č,ć,đ,ž"</string>
and you it later by string name
I have following data in my db row:
Espresso: 7,00
Double Espresso: 8,00
Ristretto: 7,00
Espresso Machiato: 8,00
Espresso Con Panna: 8,00
I write it on Word, then copy & paste to MySQL editor. When I save it, my IOS and Android apps cannot show the prices aligned because of the tab characters.
What is the best way to do that?
The best way- those 2 things are different data and are in different columns in your database, I would expect (if not, you need to fix your schema). So put the 2 strings in separate TextViews, and align the text view in xml.
First you can split the data from tab character and use formatting like below in java. I believe in objective-c it should be similar.
String ehe = String.format("%-20s : \t %4dTL \n","ehemehe",23);
String ehe2 = String.format("%-20s : \t %4dTL \n","ehemeheadawd",44);
System.out.println(ehe);
System.out.println(ehe2);
Output it produces is
ehemehe : 23TL
ehemeheadawd : 44TL
replace the "/t" chars with "" before you display the text. by using
String.replace("/t","");
Use a fixed-width font if you have precalculated the number of spaces.
I need to localize an Android app in many languages. But the text also contains a local web link like www.theLink.com, www.LinkForOtherLanguage1.it, www.yetAnotherLinkForOtherLanguage2.fr,... you get the idea :)
I know this way to linkify...
Pattern pattern = Pattern.compile("www.theLink.com");
Linkify.addLinks(textView, pattern, "http://");
But here I need to know the addresses and put them in the code. Is there any way without changing the code for each language?
Many thanks
You could put the links in a string array and get them by position according to what language it is
Pattern pattern = Pattern.compile("[a-zA-Z]+&");
myCustomLink.setText("press Linkify& or on Android& to search it on google");
Linkify.addLinks(myCustomLink,pattern, "http://www.google.ie/search?q=");
This code works perfectly but I cannot get it how patterns works and convert only Linkfy and Android as a link ???
It's a regular expression.
http://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/
http://www.regular-expressions.info/reference.html
it's saying get ' Letters followed by the &(ampersand) sign ' if you changed it to a . (fullstop) the . character has a special meaning in regex so you can't use it in this situation.
You could change it to:
[a-zA-Z]+L
then anything like:
press LinkifyL or on AndroidL to search it on google
will change to a link, get it?
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.