I am making a calculator and I need to add a -1 to the power of cos, to signify inverse cos, and I need to display this in my EditText like this. Any ideas are greatly appreciated. Also, I am using Android Studio.
Asked
Active
Viewed 221 times
0
-
yeah sorry about that, I didn't find that when I was looking... I tried the way posted there but it didn't work... when I try calling the string from the strings file, I get a null pointer exception – Adam May 29 '16 at 03:23
-
Ok... I figured the exception out... but when I use the HTML code it doesn't superscript it it just displays the -1 normally – Adam May 29 '16 at 03:31
-
I figured it out, my case was different because i was using a string builder and that eliminated all html changes – Adam May 29 '16 at 18:03
2 Answers
0
((EditText) findViewById(R.id.editText)).setText(Html.fromHtml("cos<sup>-1</sup>"));

Linh
- 57,942
- 23
- 262
- 279

Mahbub Mukul
- 333
- 3
- 18
0
You can use SpannableString to customize the text at various points in the strong. Please see the following answer for Textview which you can adapt to EditText https://stackoverflow.com/a/14981952/4419474
-
Thanks... I used this method and have made the -1 smaller, but it is a subscript not a superscript – Adam May 29 '16 at 17:46