About SuperScript and SubScript

Put your problem here if it does not fit any of the other categories.

About SuperScript and SubScript

Postby moutazahmed » Mon Jan 07, 2008 12:16 pm

Hellow to all Android Developers and users. i am a new to Android, i need to to develope small application.

All what i want is that to write a text on the button that contain a superscript and subscript


As u know in Java Swing Object he parses this :
we only write it as
Syntax: [ Download ] [ Hide ]
  1. <html>String<sup>SuperString</sup><sub>subscript</sub></html> 



How to do that in Android Button#setText(); ??

thanks in advance
moutazahmed
Freshman
Freshman
 
Posts: 2
Joined: Mon Jan 07, 2008 11:57 am

Top

Postby plusminus » Mon Jan 07, 2008 3:47 pm

Hello moutazahmed,

i don't think that Android-Widgets (like the Button) are capable of parsing HTML-Code.

You could create your own custom View, that could contain a WebView, which of course is capable of doing what you want.
Tutorial on :src: how to create Custom Views (click).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby moutazahmed » Mon Jan 07, 2008 3:59 pm

thank u for ur quick reply, but i read this article and don't know how to handle the html subscript and superscript from xml files ????

i don't know how to parse and how to draw

i see that it is another case ?
moutazahmed
Freshman
Freshman
 
Posts: 2
Joined: Mon Jan 07, 2008 11:57 am

Postby plusminus » Mon Jan 07, 2008 4:37 pm

Hello moutazahmed,

I was thinking of sth. like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         /* We will show the data we read in a WebView. */
  2.  
  3.         WebView wv = new WebView(this);
  4.  
  5.                                
  6.  
  7.         /* Show the String on the GUI. */
  8.  
  9.         wv.loadData(myString, "text/html", "utf-8");
  10.  
  11.                                
  12.  
  13.         this.setContentView("<html>String<sup>SuperString</sup><sub>subscript</sub></html>");
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


So create a custom View and make it contain code like above.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 10 guests