java - How to display fraction instead of decimal (double) in android TextView (answerview) -


i want show fractions instead of decimal value in textview(answerview)

for example - 1.0625 (this value answer calculation)

i want show 1.0625 in fractions (added sample image [required fraction image]) enter image description here 1(1/16) in textview.

this not constant value, value keeps changing according user calculations, every answer want convert fractions , display

sujay

use kexanie that

in case should set text in mathview [read kexanie readme.md]

string text = "$$" + var1 + "\\frac{" + var2 + "}{" + var3 + "}$$"; 

enter image description here

here var1 = 1, var2 = 1 , var3 = 16

add mathview in xml

<io.github.kexanie.library.mathview     android:id="@+id/formula"     android:layout_width="match_parent"     android:layout_height="wrap_content"     auto:engine="katex"     > </io.github.kexanie.library.mathview> 

then in oncreate() method

mathview mathv = (mathview) findviewbyid(r.id.formula); 

and set formula mathv

mathv.settext(text); 

or can use other libraries mentioned here


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -