How to write the Bitcoin logo as text? - android

I am developing an android app and I want to write the Bitcoin symbol in a TextView.
Is there any code for that like "\u20B9" for Rupees?

Android supports Bitcoin Unicode symbol since Android O, you can read more about it from this link. Just try to run your code in Android O and I'm sure that everything will be fine.
But if still want to use TextView, to show BTC symbol, consider FontAwesome, it's actually designed for WEB, but it also possible to use in Android.
Download icons pack.
Put ttf font file to your assets folder
Then get Typeface object and set it to your TextView:
String fontName = "fa-brands-400.ttf";
Typeface fontAwesome = Typeface.createFromAsset(getAssets(), "fonts/" + fontName);
textView.setTypeface(fontAwesome);
Add string XML resource with FontAwesome code point of BTC symbol:
<string name="btc_fa"></string>
Set this string to TextView:
textView.setText(R.string.btc_fa);
As the result, you will get this:

Create a string in strings.xml like the following one:
<string name="bitCoin">\u20BF</string>
Use the following to create the textView with BitCoin Symbol:
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="#string/bitCoin"/>
You will have your bitcoin symbol in textView like below

Related

Weird characters while displaying hindi text in android

I want to display some text in hindi that I am getting from server.
While showing the text some weird characters are displayed (à¤à¥à¤¸à¥à¤à¤¿à¤à¤).
But in iOS its showing perfectly
I think its some encoding issue
By default Android phone (Now some does support) doesn’t support Devanagari fonts. However if you want to use hindi, tamil, bangali or other Devanagari fonts in your Android Application you have an alternative of using external fonts.
Follow these steps...
Download an external Devanagari font that you like to use in your application.
ex. (Verdana.ttf or anand-lipi-bold)
Create a new folder “fonts” under assets and copy the downloaded .ttf font to your assets/font folder.
then Load .ttf to your TextView.
TextView tv = (TextView) findViewById(R.id.textView);
Typeface fontHindi = Typeface.createFromAsset(getAssets(),
"fonts/Ananda Lipi Bold Cn Bt.ttf");
tv.setTypeface(fontHindi);
tv.setText("Hindi font");
Hope this will help you.
Please use below Code for getting string
new String("Your String".getBytes("ISO-8859-1"), "utf-8")
I was also getting some arabic string from server and it was displaying some chaaracters like yours but after using this it solved
Here instead of ISO-8859-1 you can use encode type in which data is encoded on server side
Finally got an answer myself
I am using volley as my networking library and by default its encoding was in latin-1
So after changing to utf-8 it worked perfectly
Thanks everyone for your help

How to add Currency Symbols in pdf, generated by my application?

I want to add currency symbols in pdf report, generated by my android application. String symbols i am adding to the file... but its not displaying. Is there any solution? Do i need to use any fonts or encoding for that?
If you need to use just a few currency signs then you may use a walk around for for some symbols, for example for the Euro sign in PDF using the built-in pdf font Helvetica with the 1252 code page:
BaseFont helvetica = BaseFont.createFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(helvetica, 12, Font.NORMAL);
Chunk chunk = new Chunk("Euro symbol: 20\u20ac.", font);
document.add(chunk);
But if you are looking to support all currency symbols then you should use the unicode enabled font (like Arial Unicode MS) and embed it into output PDF. You may find the complete list of Unicode currency symbols at unicode.org.

Displaying Malayalam Unicode fonts in android webview

I am developing an Android RSS reader.
My work almost done, but I have problem with Malayalam Unicode fonts when I display them using WebView.
I use following method to display RSS feeds:
String CurrentDescription = headlinesarray.Description[Number];
Description.loadDataWithBaseURL (null, "<html><head><style>#font-face{font-family:'MeeraRegular'; src: url('file:///android_asset/fonts/Meera.ttf');}body{font-family:'MeeraRegular'; font-size:20px; } </style></head><body>"+CurrentDescription+"</body></html>", "text/html", "UTF-8",
null);
When I use this method, it displays Malayalam fonts, but not properly.Many charecters are misplaced.And its so difficult to read.
Here is a screen shot:
Finally I have found a solution.I converted Unicode fonts to Ascii,by replacing each and every Unicode charecters with Ascii.Here I use MLTT-Karthika as Ascii font.Then set this font in typeface.
t=(TextView) findViewById(R.id.text);
Typeface typeFace = Typeface.createFromAsset(getAssets(),"karthika.TTF");
t.setTypeface(typeFace);
String CurrentDecription;
String s2=s.toLowerCase().replaceAll("അ", "A").replaceAll("ആ","B")
.replaceAll("ഇ","C")
.replaceAll("ഈ","Cu")
.replaceAll("ഉ","D")
.replaceAll("ഊ","Du")
.replaceAll("ഋ","E")
.replaceAll("എ","F")
.replaceAll("ഏ","G")
.replaceAll("ഐ","sF")
.replaceAll("ഒ","H")
.replaceAll("ഓ","Hm")
.replaceAll("ഔ","Hu")
.replaceAll("ക്തേ","tà").replaceAll("ക്തെ","sà").replaceAll("ക്ത്യ","ày").replaceAll("ക്തൈ","ssà").replaceAll("ക്ത","à").replaceAll("ക്ഷ്യ","£y").replaceAll("ക്ഷെ","s£").replaceAll("ക്ഷേ","t£").replaceAll("ക്ഷൈ","ss£").replaceAll("ക്ഷ","£").replaceAll("ക്ടെ","sÎ").replaceAll("ക്ടേ","tÎ").replaceAll("ക്ട","Î").replaceAll("ങ്കെ","s¦").replaceAll("ങ്കേ","t¦").replaceAll("ങ്കൈ","ss¦").replaceAll("ങ്ക","¦").replaceAll("ക്ലെ","s¢").replaceAll("ക്ലേ","t¢").replaceAll("ക്ലൈ","ss¢").replaceAll("ക്ല","¢").replaceAll("ക്കേ","t¡").replaceAll("ക്കോ","t¡m").replaceAll("ക്കെ","s¡").replaceAll("കൊ","sIm").replaceAll("കെ","sI").replaceAll("കോ","tIm").replaceAll("കേ","tI").replaceAll("ക്വ","Iz").replaceAll("ക്രൈ","ss{I").replaceAll("ക്രോ","t{Im").replaceAll("ക്രേ","t{I").replaceAll("ക്രൊ","s{Im").replaceAll("ക്രെ","s{I").replaceAll("ക്ര","{I").replaceAll("ക്യ","Iy").replaceAll("ക്കൈ","ss¡").replaceAll("ക്ക","¡").replaceAll("കൈ","ssI").replaceAll("ക","I")
.replaceAll("ഖേ","tJ").replaceAll("ഖൈ","ssJ").replaceAll("ഖെ","sJ").replaceAll("ഖ്വ","Jz").replaceAll("ഖ്യ","Jy").replaceAll("ഖ","J")
.replaceAll("ഗ്ലെ","s¥").replaceAll("ഗ്ലേ","t¥").replaceAll("ഗ്ലൈ","ss¥").replaceAll("ഗ്ല","¥").replaceAll("ഗ്ഗേ","t¤").replaceAll("ഗ്ഗൈ","ss¤").replaceAll("ഗ്ഗെ","s¤").replaceAll("ഗൈ","ssK").replaceAll("ഗൊ","sKm").replaceAll("ഗെ","sK").replaceAll("ഗ്വ","Kz").replaceAll("ഗ്യ","Ky").replaceAll("ഗൃ","Kr").replaceAll("ഗ്രൈ","ss{K").replaceAll("ഗ്ര","{K").replaceAll("ഗ്ഗ","¤").replaceAll("ഗോ","tKm").replaceAll("ഗേ","tK").replaceAll("ഗ","K")
.replaceAll("ഘൈ","ssL").replaceAll("ഘൊ","sLm").replaceAll("ഘെ","sL").replaceAll("ഘോ","tLm").replaceAll("ഘേ","tL").replaceAll("ഘ","L")
.replaceAll("ങ്ങൈ","ss§").replaceAll("ങ്ങെ","s§").replaceAll("ങ്ങേ","t§").replaceAll("ങ്ങ്യ","§y").replaceAll("ങ്ങ","§").replaceAll("ങേ","tM").replaceAll("ങൈ","ssM").replaceAll("ങെ","sM").replaceAll("ങ","M")
.replaceAll("ഞ്ചൈ","ss©").replaceAll("ഞ്ചെ","s©").replaceAll("ഞ്ചേ","t©").replaceAll("ഞ്ച്യ","©y").replaceAll("ഞ്ച","©").replaceAll("ച്ചേ","t¨").replaceAll("ച്ചൈ","ss¨").replaceAll("ച്ചെ","s¨").replaceAll("ചോ","tNm").replaceAll("ചേ","tN").replaceAll("ചൈ","ssN").replaceAll("ചൊ","sNm").replaceAll("ചെ","sN").replaceAll("ച്ര","{N").replaceAll("ച്യ","Ny").replaceAll("ച്ച","¨").replaceAll("ച","N")
.replaceAll("ഛൈ","ssO").replaceAll("ഛെ","sO").replaceAll("ഛേ","tO").replaceAll("ഛ","O")
.replaceAll("ജ്ഞൈ","ssÚ").replaceAll("ജ്ഞെ","sÚ").replaceAll("ജ്ഞേ","tÚ").replaceAll("ജ്ഞ","Ú").replaceAll("ജ്ജേ","tÖ").replaceAll("ജ്ജൈ","ssÖ").replaceAll("ജ്ജെ","sÖ").replaceAll("ജ്ജ","Ö").replaceAll("ജൈ","ssP").replaceAll("ജൊ","sPm").replaceAll("ജെ","sP").replaceAll("ജ്വ","Pz").replaceAll("ജ്യ","Py").replaceAll("ജ്ര","{P").replaceAll("ജോ","tPm").replaceAll("ജേ","tP").replaceAll("ജ","P")
.replaceAll("ഝൈ","ssQ").replaceAll("ഝെ","sQ").replaceAll("ഝേ","tQ").replaceAll("ത്സ്യ","Qy").replaceAll("ഝ","Q")
.replaceAll("ഞ്ഞൈ","ssª").replaceAll("ഞ്ഞെ","sª").replaceAll("ഞ്ഞേ","tª").replaceAll("ഞ്ഞ","ª")
.replaceAll("ഞൈ","ssR").replaceAll("ഞെ","sR").replaceAll("ഞേ","tR").replaceAll("ഞ","R")
.replaceAll("ന്റെ","sâ").replaceAll("ന്റേ","tâ").replaceAll("ന്റ","â").replaceAll("ണ്ടൈ","ssî").replaceAll("ണ്ടെ","sî").replaceAll("ണ്ടേ","tî").replaceAll("ണ്ട്യ","îy").replaceAll("ണ്ട","î").replaceAll("ട്ട്യ","«y").replaceAll("ട്ടൈ","ss«").replaceAll("ട്ടെ","s«").replaceAll("ട്രൈ","ss{S").replaceAll("ട്രോ","t{Sm").replaceAll("ട്രേ","t{S").replaceAll("ട്രെ","s{S").replaceAll("ടൈ","ssS").replaceAll("ടൊ","sSm").replaceAll("ടെ","sS").replaceAll("ട്ര","{S").replaceAll("ട്വ","Sz").replaceAll("ട്യ","Sy").replaceAll("ട്ടോ","t«m").replaceAll("ട്ടേ","t«").replaceAll("ട്ട","«").replaceAll("ടോ","tSm").replaceAll("ടേ","tS").replaceAll("ട","S")
.replaceAll("ഠൈ","ssT").replaceAll("ഠെ","sT").replaceAll("ഠേ","tT").replaceAll("ഠ്യ","Ty").replaceAll("ഠ","T")
.replaceAll("ഡ്രൈ","ss{U").replaceAll("ഡ്രേ","t{U").replaceAll("ഡ്രെ","s{U").replaceAll("ഡൈ","ssU").replaceAll("ഡെ","sU").replaceAll("ഡ്ര","{U").replaceAll("ഡേ","tU").replaceAll("ഡോ","tUm").replaceAll("ഡ","U")
.replaceAll("ഢൈ","ssV").replaceAll("ഢെ","sV").replaceAll("ഢേ","tV").replaceAll("ഢ","V")
.replaceAll("ണ്മൈ","ss×").replaceAll("ണ്മെ","s×").replaceAll("ണ്മേ","t×").replaceAll("ണ്മ","×").replaceAll("ണ്ണൈ","ss®").replaceAll("ണ്ണെ","s®").replaceAll("ണൈ","ssW").replaceAll("ണെ","sW").replaceAll("ണ്‍","¬").replaceAll("ണ്ണേ","t®").replaceAll("ണ്ണ","®").replaceAll("ണേ","tW").replaceAll("ണ","W")
.replaceAll("ത്ഥൈ","ss°").replaceAll("ത്ഥെ","s°").replaceAll("ത്ഥേ","t°").replaceAll("ത്ഥ്യ","°y").replaceAll("ത്ഥ","°").replaceAll("ത്മൈ","ssß").replaceAll("ത്മെ","sß").replaceAll("ത്മേ","tß").replaceAll("ത്മ","ß").replaceAll("ത്തൈ","ss¯").replaceAll("ത്തെ","s¯").replaceAll("ന്തൈ","ss´").replaceAll("ന്തെ","s´").replaceAll("തൈ","ssX").replaceAll("തൊ","sXm").replaceAll("തെ","sX").replaceAll("ത്വ","Xz").replaceAll("ന്ത്ര","{´").replaceAll("ന്ത്യ","´y").replaceAll("ന്തേ","t´").replaceAll("ന്തോ","t´m").replaceAll("ന്ത","´").replaceAll("ത്യേ","tXy").replaceAll("ത്യ","Xy").replaceAll("തൃ","Xr").replaceAll("ത്രൈ","ss{X").replaceAll("ത്രോ","t{Xm").replaceAll("ത്രൊ","t{Xm").replaceAll("ത്രേ","t{X").replaceAll("ത്രെ","s{X").replaceAll("ത്ര","{X").replaceAll("ത്തേ","t¯").replaceAll("ത്ത","¯").replaceAll("തോ","tXm").replaceAll("തേ","tX").replaceAll("ത","X")
.replaceAll("ഥൈ","ssY").replaceAll("ഥെ","sY").replaceAll("ഥേ","tY").replaceAll("ഥ","Y")
.replaceAll("ദ്ധേ","t²").replaceAll("ദ്ധൈ","ss²").replaceAll("ദ്ധെ","s²").replaceAll("ദ്ധ","²").replaceAll("ബ്ദൈ","ssÐ").replaceAll("ബ്ദെ","sÐ").replaceAll("ബ്ദേ","tÐ").replaceAll("ബ്ദ","Ð").replaceAll("ന്ദൈ","ssµ").replaceAll("ന്ദെ","sµ").replaceAll("ന്ദേ","tµ").replaceAll("ന്ദ്രേ","t{µ").replaceAll("ന്ദ്രൈ","ss{µ").replaceAll("ന്ദ്രെ","s{µ").replaceAll("ന്ദ്ര","{µ").replaceAll("ന്ദ","µ").replaceAll("ദ്ദൈ","ss±").replaceAll("ദ്ദെ","s±").replaceAll("ദ്ദേ","t±").replaceAll("ദ്ദ","±").replaceAll("ദൈ","ssZ").replaceAll("ദെ","sZ").replaceAll("ദ്വൈ","ssZz").replaceAll("ദ്വേ","tZz").replaceAll("ദ്വ","Zz").replaceAll("ദ്യെ","sZy").replaceAll("ദ്യേ","tZy").replaceAll("ദ്യ","Zy").replaceAll("ദൃ","Zr").replaceAll("ദേ","tZ").replaceAll("ദ","Z")
.replaceAll("ബ്ധെ","sÏ").replaceAll("ബ്ധേ","tÏ").replaceAll("ബ്ധ","Ï").replaceAll("ന്ധ്രെ","s{Ô").replaceAll("ന്ധ്യ","Ôy").replaceAll("ന്ധ്ര","{Ô").replaceAll("ന്ധെ","sÔ").replaceAll("ന്ധേ","tÔ").replaceAll("ന്ധ","Ô").replaceAll("ധൈ","ss[").replaceAll("ധെ","s[").replaceAll("ധ്യ","[y").replaceAll("ധൃ","[r").replaceAll("ധേ","t[").replaceAll("ധ","[")
.replaceAll("ന്‍െറ","sâ").replaceAll("ന്‍േറ","tâ").replaceAll("ന്റെ","sâ").replaceAll("ന്റേ","tâ").replaceAll("ന്‍റ","â").replaceAll("ന്റ","â").replaceAll("ന്‍","³").replaceAll("ന്‍","³").replaceAll("ന്നൈ","ss¶").replaceAll("ന്നെ","s¶").replaceAll("ന്നേ","t¶").replaceAll("ന്ന","¶").replaceAll("ന്മൈ","ss∙").replaceAll("ന്മെ","s∙").replaceAll("ന്മേ","t∙").replaceAll("ന്മ","∙").replace("നൈ","ss\\").replace("നൊ","s\\m").replace("നെ","s\\").replace("ന്വേ","t\\z").replace("ന്വെ","s\\z").replace("ന്വ","\\z").replace("ന്യ","\\y").replace("നോ","t\\m").replace("നേ","t\\").replace("ന","\\")
.replaceAll("മ്പൈ","ss¼").replaceAll("മ്പെ","s¼").replaceAll("മ്പ്യ","¼y").replaceAll("മ്പേ","t¼").replaceAll("മ്പ","¼").replaceAll("ല്പെ","så").replaceAll("ല്പേ","tå").replaceAll("ല്പ","å").replaceAll("പ്ലേ","ts¹").replaceAll("പ്ലൈ","ss¹").replaceAll("പ്ലെ","s¹").replaceAll("പ്ല","¹").replaceAll("പ്പേ","t¸").replaceAll("പ്പൈ","ss¸").replaceAll("പ്പെ","s¸").replaceAll("പൈ","ss]").replaceAll("പൊ","s]m").replaceAll("പെ","s]").replaceAll("പ്യ","]y").replaceAll("പ്രേ","t{]").replaceAll("പ്രൈ","ss{]").replaceAll("പ്രെ","s{]").replaceAll("പ്ര","{]").replaceAll("പ്പേ","t¸").replaceAll("പ്പ","¸").replaceAll("പോ","t]m").replaceAll("പേ","t]").replaceAll("പ","]")
.replaceAll("ഫ്ലൈ","^vssf").replaceAll("ഫ്ലെ","^vsf").replaceAll("ഫ്ലേ","^vtf").replaceAll("ഫ്ല","^vf").replaceAll("ഫൈ","ss^").replaceAll("ഫൊ","s^m").replaceAll("ഫെ","s^").replaceAll("ഫോ","t^m").replaceAll("ഫേ","t^").replaceAll("ഫ്ര","{^").replaceAll("ഫ","^")
.replaceAll("ബ്ലൈ","ss»").replaceAll("ബ്ലെ","s»").replaceAll("ബ്ലേ","t»").replaceAll("ബ്ല","»").replaceAll("ബ്ബൈ","ssº").replaceAll("ബ്ബെ","sº").replaceAll("ബൈ","ss_").replaceAll("ബൊ","s_m").replaceAll("ബെ","s_").replaceAll("ബ്രേ","t{_").replaceAll("ബ്രൈ","ss{_").replaceAll("ബ്രെ","s{_").replaceAll("ബ്ര","{_").replaceAll("ബ്ബേ","tº").replaceAll("ബ്ബ","º").replaceAll("ബോ","t_m").replaceAll("ബേ","t_").replaceAll("ബ","_")
.replaceAll("ഭൈ","ss`").replaceAll("ഭെ","s`").replaceAll("ഭ്വ","`z").replaceAll("ഭ്ര","{`").replaceAll("ഭ്യ","`y").replaceAll("ഭൃ","`r").replaceAll("ഭേ","t`").replaceAll("ഭ","`")
.replaceAll("മ്മൈ","ss½").replaceAll("മ്മെ","s½").replaceAll("മൈ","ssa").replaceAll("മൊ","sam").replaceAll("മെ","sa").replaceAll("മ്യ","ay").replaceAll("മൃ","ar").replaceAll("മ്മേ","t½").replaceAll("മ്മ","½").replaceAll("മോ","tam").replaceAll("മേ","ta").replaceAll("മ","a")
.replaceAll("ല്യ","ey").replaceAll("ര്യ","cy").replaceAll("ഷ്യ","jy").replaceAll("ഹ്യ","ly").replaceAll("സ്യേ","tky").replaceAll("സ്യ","ky").replaceAll("ശ്യ","iy").replaceAll("വ്യ","hy").replaceAll("യ്യൈ","ss¿").replaceAll("യ്യെ","s¿").replaceAll("യോ","tbm").replaceAll("യൈ","ssb").replaceAll("യെ","sb").replaceAll("യ്യേ","t¿").replaceAll("യ്യ","¿").replaceAll("യേ","tb").replaceAll("യ","b")
.replaceAll("ഹ്ര","{l").replaceAll("സ്രേ","t{k").replaceAll("സ്ര","{k").replaceAll("വ്ര","{h").replaceAll("ശ്രേ","t{i").replaceAll("ശ്ര","{i").replaceAll("രൈ","ssc").replaceAll("രൊ","scm").replaceAll("രെ","sc").replaceAll("ര്വ","cz").replaceAll("ര്‍","À").replaceAll("ര്‍","À").replaceAll("ര്യ","cy").replaceAll("രോ","tcm").replaceAll("രേ","tc").replaceAll("ര","c")
.replaceAll("റ്റൈ","ssä").replaceAll("റ്റെ","sä").replaceAll("റ്റേ","tä").replaceAll("റ്റോ","täm").replaceAll("റ്റ","ä").replaceAll("റൈ","ssd").replaceAll("റെ","sd").replaceAll("റേ","td").replaceAll("റ","d")
.replaceAll("ഹ്ലെ","sË").replaceAll("ഹ്ലേ","tË").replaceAll("ഹ്ല","Ë").replaceAll("ശ്ലെ","sÇ").replaceAll("ശ്ലേ","tÇ").replaceAll("ശ്ല","Ç").replaceAll("ല്ലൈ","ssÃ").replaceAll("ല്ലൊ","sÃm").replaceAll("ല്ലെ","sÃ").replaceAll("ലൈ","sse").replaceAll("ലൊ","sem").replaceAll("ലെ","se").replaceAll("ല്ല്വ","Ãz").replaceAll("ല്ല","Ã").replaceAll("ല്‍","Â").replaceAll("ല്‍","Â").replaceAll("ല്ല്യ","Ãy").replaceAll("ല്ലോ","tÃm").replaceAll("ല്ലേ","tÃ").replaceAll("ല്ല","Ã").replaceAll("ലോ","tem").replaceAll("ലേ","te").replaceAll("ല","e")
.replaceAll("ള്ള","Å").replaceAll("ള്‍","Ä").replaceAll("ള്‍","Ä").replaceAll("ള്ളൈ","ssÅ").replaceAll("ള്ളെ","sÅ").replaceAll("ളൈ","ssf").replaceAll("ളെ","sf").replaceAll("ള്ള","Å").replaceAll("ള്ളേ","tÅ").replaceAll("ളേ","tf").replaceAll("ള","f")
.replaceAll("ഴൈ","ssg").replaceAll("ഴെ","sg").replaceAll("ഴേ","tg").replaceAll("ഴ","g")
.replaceAll("ഷ്വൈ","ssjz").replaceAll("ഷ്വെ","sjz").replaceAll("ഷ്വ","jz").replaceAll("ഹ്വ","lz").replaceAll("സ്വേ","tkz").replaceAll("സ്വൈ","sskz").replaceAll("സ്വെ","skz").replaceAll("സ്വ","kz").replaceAll("വ്വൈ","ssÆ").replaceAll("വ്വെ","sÆ").replaceAll("വൈ","ssh").replaceAll("വെ","sh").replaceAll("ശ്വേ","tiz").replaceAll("ശ്വ","iz").replaceAll("വ്വേ","tÆ").replaceAll("വ്വ","Æ").replaceAll("വേ","th").replaceAll("വോ","thm").replaceAll("വ","h")
.replaceAll("ശ്ശൈ","ssÈ").replaceAll("ശ്ശെ","sÈ").replaceAll("ശൈ","ssi").replaceAll("ശൊ","sim").replaceAll("ശെ","si").replaceAll("ശ്രേ","t{i").replaceAll("ശ്ര","{i").replaceAll("ശ്ശേ","tÈ").replaceAll("ശ്ശ","È").replaceAll("ശോ","tim").replaceAll("ശേ","ti").replaceAll("ശ","i")
.replaceAll("ഷൈ","ssj").replaceAll("ഷെ","sj").replaceAll("ഷേ","tj").replaceAll("ഷ","j")
.replaceAll("സ്സൈ","ssÊ").replaceAll("സ്സെ","sÊ").replaceAll("സൈ","ssk").replaceAll("സെ","sk").replaceAll("സ്സ","Ê").replaceAll("സ്സേ","tÊ").replaceAll("സേ","tk").replaceAll("സോ","tkm").replaceAll("സ","k")
.replaceAll("ഹൈ","ssl").replaceAll("ഹെ","sl").replaceAll("ഹേ","tl").replaceAll("ഹ","l")
.replaceAll("ാ","m")
.replaceAll("ി","n")
.replaceAll("ീ","o")
.replaceAll("ു","p")
.replaceAll("ൂ","q")
.replaceAll("ഃ","x")
.replaceAll("്","v")
.replaceAll("ം","w")
.replaceAll("ൗ","u")
.replaceAll("ൃ","r")
;
t.setText(s2);
basim, i have one solution. may be this will help you
download salilam ttf file from this link and place this filename instead of malayalam.fnt
http://www.prokerala.com/downloads/fonts.php
add ur font file in assets folder of your project, then with the help of setTYpeface() function set the font for textview.
Typeface typeFace = Typeface.createFromAsset(getAsset(),"malyalam.fnt");
and then add it to your textview like below
textView.setTypeFace(typeFace);
hope this will work for u,
i have sent those code files to ur mail, basim.sherif#gmail.com
Switch your text encoding to UTF-8.
In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.
https://stackoverflow.com/a/5857671/1933926

Android : display html data

I want to display the content of an html page and an image to the right of that in my view.
So i have defined my layout as
<ScrollView android:id="#+id/scrllvwNo1"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="fill_parent" android:background="#drawable/home_bg">
<ImageView android:id="#+id/aboutcmkimage"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:src="#drawable/about"
android:padding="5dip" />
<WebView android:id="#+id/aboutcmk" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:textColor="#000000"
android:layout_toLeftOf="#+id/aboutcmkimage"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true" />
</RelativeLayout>
</ScrollView>
and
I try to load the html page as below
WebView web = (WebView)findViewById(R.id.aboutcmk);
web.loadData(getString(R.layout.about),"texl/html","utf-8");
in this case i am getting the error
"this page contains error at line1 ... "
if I try
web.loadDataWithBaseURL(null,getString(R.layout.about),"texl/html","utf-8",null);
no html output and no error
In both case the image is coming
Can anyone help me in debugging
My html has bullets , so i cannot use textview instead of webview
here is the definition of my htmlstring in xml file
<string name="About"><html><body><b>What is CMK?</b> ......</body></html>
Thanks a lot for the help
are you put this line What is CMK? ...... in strings.xml if yes then the correction is in this line
web.loadDataWithBaseURL(null,getString(R.layout.about),"texl/html","utf-8",null);
Correct one:
web.loadDataWithBaseURL(null, getString(R.string.About), "text/html", "UTF-8", null);
First of all, if you have saved your HTML specification as a string resource, your should access it as R.string.about and not R.layout.about. Change that, if it still doesn't work, try escaping the less than characters in your string, like this :
<string name="about"><html><body><b>What is CMK?</b> ......</body></html> </string>
I think you will have to escape the less than characters. Before loading the text, Log it. You'll see the problem.
Instead of storing the HTML in strings.xml, you can store it in its own file in the res/raw/ directory. For example, let's say you save the file in res/raw/mypage.html. I haven't tested this, but you should be able to open up raw resources and load them up in a WebView like:
try {
Resources resources = getResources();
InputStream inputStream = resources.openRawResource(R.raw.mypage);
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
String htmlStr = new String(bytes);
webView.loadData(htmlStr, "text/html", "UTF-8");
} catch(Exception e) {
//blah
}

Specifying drawable resource id in a separate xml

I have an xml file that specifies a set of image button names. Also, I would like to specify the image resource id as an attribute of an xml node as shown below:
<button name="close" resLocation="R.drawable.close" />
I am parsing the xml in the code, I would like to set the image background for the dynamically created button using the resLocation attribute. Since resLocation is a string, I cannot convert to a Drawable object directly. Is there a way I can workaround?
You can use get getResources().getIdentifier:
String myResourceId = "close"; // Parsed from XML in your case
getResources().getIdentifier(myResourceId, "drawable", "com.my.package.name");
This would require your XML to be a little different:
<button name="close" resLocation="close" />
If you need to keep the R.type.id format in your XML, then you would just need to parse out the type and id:
String myResourceId = "R.drawable.close";
String[] resourceParts = myResourceId.split("\\.");
getResources().getIdentifier(resourceParts[2], resourceParts[1], "com.my.package.name");
You can try
<button name="close" resLocation="#drawable/close" />
or try
ImageButton imgButton=new ImageButton(this);
imgButton.setImageResource(getResources().getDrawable(R.drawable.close));

Categories

Resources