I'm trying to display this Unicode character in a Toast message:
http://graphemica.com/%E2%AE%8C
It is embedded in a Xml file that contains all the strings of the Android application, like this
<string name="back_press">Click again ⮌ to exit</string>
The message shown from the Toast is the one in the image
toast message
Can you help me to solve this problem?
Thank you in advance.
You should use the Unicode character, in your case U+2B8C and replace U+ by 1x, but you should look for another icon because that one doesn't exist, search one you like in here.
For this example I've used the back arrow:
int unicode = 0x2B05;
String textIcon = new String(Character.toChars(unicode));
Toast.makeText(getApplicationContext(), "Your text here" + textIcon, Toast.LENGTH_LONG).show();
And that should view your icon.
Related
I am beginning learning some android mobile development and have created a notepad app through some tutorials and am now wanting to customise it a little.
I currently have a Toast maketext message that displays when a user saves a new note. The code is as follows:
if(Utilities.saveNote(this, new Note(mNoteCreationTime, title, content)))
Toast.makeText(this, "Swag Note has been saved", Toast.LENGTH_SHORT).show();
What I am wanting to do is add a small icon at both ends of this toast message.
Is there a relatively simple way of achieving this?
Toasts cannot have icons. You can create a custom Toast with ImageViews in it (example). However, there might be an unicode symbol that suits your purpose: in that case, you can just paste it.
Edit:
To make the linked example work, you'd just have to add a View for the image with id "toast_image", which will be invoked this way:
ImageView image = (ImageView) layout.findViewById(R.id.toast_image);
Show Toast as you do it now:
Toast.makeText(this, "Swag Note has been saved", Toast.LENGTH_SHORT).show();
Show MyToast from linked example:
MyToast.show(this, "Swag Note has been saved", false);
FormattedString t = new FormattedString();
t.Spans.Add(new Span() { Text = "About my Self\n\n" });
t.Spans.Add(new Span() { Text = "1. My website\n\n" });
t.Spans.Add(new Span() { Text = "2. My Linkedin profile\n\n" });
t.Spans.Add(new Span() { Text = "3. Twitter\n\n" });
I have a Text like above, I am able to set hyperlink whole text but I want to set a hyperlink for website and Linkedin words with some URL.
How can I set hyperlink for particular word in Paragraph for Label
Please help me on that.Thanks!!
As far as I know, there is no way to do that, your best choice is to create multiple labels or add a gesture recognizer for the whole text, wich would be a better idea since clicking on a small word is difficult on certain devices and the gesture recognizers on Xamarin are not the best ones around.
This might help for you: AwesomeHyperLinkLabel . I myself looking way to implement this and will start with this link, but I want to improve it a bit and replace links text with friendly text so instead direct link to page it would say "my page"
Basically, i have a list of Nepali Unicode strings something like {"युनिकोड १ ","युनिकोड २","युनिकोड ३"}.
Now, Firstly, I have a text view in Xamarin (Android) and tried to set the text property using couple of methods:
UnicodeTextView.Text="युनिकोड १"; //direct method
var font = Typeface.CreateFromAsset(_activity.Assets, "kantiput.TTF");//kantiput.TTF Is a Nepali font.
UnicodeTextView.Typeface = font;
var font = Typeface.CreateFromAsset(_activity.Assets, "kantiput.TTF");
UnicodeTextView.SetTypeface(font, TypefaceStyle.BoldItalic);
and none of them worked.
When using the first option nothing was displayed, and on working with last two
and there were some BOX character visible.
For first case when i directly tried to set the value:
Before setting value:
After setting value:
Samething with the ListAdapter.
Can anyone suggest me how can we display unicode sentences in TextView, EditText, Toast ?
I want result something like this :
with TextView :
and here is the weird behavior :
and i tried all those code that are in comment too. Still didn't find any luck.
I am working in android.
In toast I checked like the following:
Toast.makeText (this, "\u0c05 \u0c06", Toast.LENGTH_SHORT).Show();
For first two letters of Telugu alphabet s. It worked.
If you have the font file you can obtain unicode codes for the various glyphs in the online software available at
https://opentype.js.org/index.html
Under page glyph inspector.
I tested your code, the first direct method UnicodeTextView.Text="युनिकोड १"; works fine by my side both with single TextView or TextView in ListView.
Or you may try this code:
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.Build.VERSION_CODES.N)
{
UnicodeTextView.Text = Android.Text.Html.FromHtml("युनिकोड १", Android.Text.FromHtmlOptions.ModeLegacy).ToString();
}
else
{
UnicodeTextView.Text = Android.Text.Html.FromHtml("युनिकोड १").ToString();
}
The title says it all. I am trying to make a calculator and of course, a calculator has a division symbol. The text of the button in the XML file can be changed to an obelus but pressing the button can't input the symbol in the Edittext. Instead, a diamond with a questionmark pops out instead. I am also having a problem with the multiplication symbol(not just the letter x but the right multiplication symbol)
Here is a code snippet:
if(Character.isDigit(temp.charAt(temp.length()-1))) {
editText.append("÷");
decf = 2;
ansf = 0;
btnDel.setText("DEL");
}
Got to be an encoding issue. Try "\u00F7"
Here's the docs:
http://www.fileformat.info/info/unicode/char/00f7/index.htm
I have the following TextView in my XML layout file:-
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/autolink_test"
android:autoLink="all"
/>
The string autolink_test contains a phone number, an email address, a website address and a physical geographical address.
While the first three are showing up correctly as clickable autolinks, the address does not. Only the zipcode part shows up as an autolink... and that too as a phone number! (When I click it, the phone dialer starts up with that number).
Any help would be appreciated.
Alternative to it, in case if autolink doesn't work
Add links to your texview . Get it underline as folows :
SpannableString spanStr = new SpannableString(buf.toString());
spanStr.setSpan(new UnderlineSpan(), 0, spanStr.length(), 0);
iTextView.setText(spanStr);
Use the following code to open it with map app on click as follows :
Intent geoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q="
+iTextView.getText().toString()));
startActivity(geoIntent);
OK, I figured out what was causing the problem. Just thought I will leave the answer here in case someone else runs into the same problem.
If the street address is not properly capitalized, it is not read properly as the address!
Here is my XML autolink_test string:
<string name="autolink_test">Name: New York Times \n
Email: public#nytimes.com \n
Phone: 212-556-7652 \n
Address: 620 Eighth Avenue New York, NY 10018 \n
Address: 620 Eighth avenue New York, NY 10018 \n
Website: http://www.nytimes.com
</string>
The first address shows up correctly as an autolink.
The second one (with a small 'a' in 'avenue') does not show up correctly.
This seems a little strange to me as the google maps website certainly doesn't care about such niceties.
Anyways, so here it is :-)