How do you change text to bold in Android?

How do you change text/font settings in an Android TextView? For example, how do you make the text bold? 22 s 22 To do this in the layout.xml file: android:textStyle Examples: android:textStyle=”bold|italic” Programmatically the method is: setTypeface(Typeface tf) Sets the typeface and style in which the text should be displayed. Note that not all Typeface … Read more

Android: combining text & image on a Button or ImageButton

I’m trying to have an image (as the background) on a button and add dynamically, depending on what’s happening during run-time, some text above/over the image. If I use ImageButton I don’t even have the possibility to add text. If I use Button I can add text but only define an image with android:drawableBottom and … Read more

Best way to convert text files between character sets?

What is the fastest, easiest tool or method to convert text files between character sets? Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa. Everything goes: one-liners in your favorite scripting language, command-line tools or other utilities for OS, web sites, etc. Best solutions so far: On Linux/UNIX/OS X/cygwin: Gnu iconv suggested … Read more

How to remove spaces from a string using JavaScript?

How to remove spaces in a string? For instance: Input: ‘/var/www/site/Brand new document.docx’ Output: ‘/var/www/site/Brandnewdocument.docx’ 13 s 13 This? str = str.replace(/\s/g, ”); Example var str=”/var/www/site/Brand new document.docx”; document.write( str.replace(/\s/g, ”) ); Update: Based on this question, this: str = str.replace(/\s+/g, ”); is a better solution. It produces the same result, but it does it … Read more

Limit text length to n lines using CSS

Is it possible to limit a text length to “n” lines using CSS (or cut it when overflows vertically). text-overflow: ellipsis; only works for 1 line text. original text: Ultrices natoque mus mattis, aliquam, cras in pellentesque tincidunt elit purus lectus, vel ut aliquet, elementum nunc nunc rhoncus placerat urna! Sit est sed! Ut penatibus … Read more

Print string to text file

I’m using Python to open a text document: text_file = open(“Output.txt”, “w”) text_file.write(“Purchase Amount: ” ‘TotalAmount’) text_file.close() I want to substitute the value of a string variable TotalAmount into the text document. Can someone please let me know how to do this? 7 s 7 It is strongly advised to use a context manager. As … Read more