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
Related
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
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.
<string name="message">هذا المجلد يحتويى على %1$s ملفات. الرجاء التأكد قبل الحذف. الملفات المحذوفة غير قابلة للإسترجاع.</string>
I wanna put "%1$s" in an arabic string, but as you can see here, word, notepad++, utraedit, all failed to get the right string. how you guys edit arabic string?
In android Studio 2, RTL support is not turned on by default,
Configure it Manually:
1. In your Computer, go to the [android-studio2.0]/bins/idea.properties
2. add editor.new.rendering=true to the end of idea.properties
3. restart your android studio.
This is a source of frustration when editing mixed-direction text. What counts is the logical order of the text, not how any of the editors display it. When you finally format the string at run time in the app, the %1$s will be replaced by whatever string you pass to the formatting method. The only thing that matters is how the string will be rendered after the substitution.
The easiest thing to do is to write the message without the %1$s, then position the insertion caret, paste in the format code, and simply ignore how the editors screw up the bidi analysis. (The screw-up is because the editors are using a left-to-right base level. In some editors, you can set the base flow to right-to-left, but then the xml markup ends up being unreadable.)
When I work with RTL text and I need to put a place holder(%1$s) or LTR words, I just write it in MS Word and copy to the IDE.
It works for me in Eclipse and Android Studio.
All you need to check is that the components that displays that string like TextView has the right gravity.
You can try in Activity..
String formatedString = String.format("%1$s", getString(R.string.your_string));
I am trying to create a database for an android app including, in part, non-English words which require underlines and accents for proper spelling. I set my encoding for this package to utf-8, which allowed the accented characters to store and display properly. However, I cannot seem to get a single character underlined. It displays an empty box for an unrecognized character.
An example of my database helper to create the sqlite is as follows:
cv.put(ENGLISH, "to be alive");
cv.put(NATIVE, "okch_á_a or okchaha");
cv.put(PART_OF_SPEECH, "verb");
cv.put(AUDIO, "alive");
cv.put(VIDEO, "none");
cv.put(IMAGE_DEFAULT, "none");
cv.put(IMAGE_OPTIONAL, "none");
cv.put(IMAGE_TO_USE, "none");
db.insert("words", ENGLISH, cv);
That
_ a _
is the best I can come up with so far, but the a should actually be an underlined character.
I tried html tags like u and /u:
<u>a</u>
since that works with string arrays, but it displays as:
<u>a</u>
(the html is never interpreted).
I tried using:
"\u0332"
as explained at http://www.fileformat.info/info/unicode/char/332/index.htm , but that, too, is never interpreted, so it displays as:
a\u0332
I also tried:
& # 818 ;
and:
& # x332 ;
in a similar manner, with similar lack of results.
Any ideas?
You can store your string in Html format and call .setText(Html.fromHtml(somestring)) from the textview were you want to display it.
I am creating an android application. The first thing I'm creating is a login activity. I am trying to limit the username edittext just to text/numbers only (no special characters). Is there a way to adjust this in the xml file?
I dont think you can limit the characters from xml. You could always use a InputFilter, but specifically android provides UsernameFilterGeneric to filter valid user names. You could also use UsernameFilterGMail
As you already use in java Regular expression.called the same class here for checking for particular field.
let me know if you want some more if you didn't know about the RE.