Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:00:23+00:00 2026-06-09T10:00:23+00:00

I need to be able to loop through all my elements and set it

  • 0

I need to be able to loop through all my elements and set it to a Textview. However, I also need my numbers to be formatted to subscript. I tried doing so by using a loop but only the last number was formatted correctly.

For example, if I entered Fe2Zn7Ag4, only the “4” will be in subscript and the rest will be like normal.
Here is my code:

Spanned EF = Html.fromHtml("");
for(int g = 0; g < numSaved; g++)
{
    EF = Html.fromHtml(EF + savedChem[g].getFormula());
    if(!(savedChem[g].getMoles().equals("1")) && !(savedChem[g].getMoles().equals("0")))
        EF = Html.fromHtml(EF + "<sub>" + savedChem[g].getMoles() + "</sub>");
}
EmpiricalFormula.setText(findEmpirical());

Also, anything that is subscript gets cut in half. When I run the program, only the top half of the subscript number will appear.

Any idea how to fix both of this issues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:00:25+00:00Added an answer on June 9, 2026 at 10:00 am

    I found my answer. Turns out Html.fromHtml() converts my previous Spanned object into a String every loop so you only end with the last one. I fixed this with the following code:

    Spanned[] E = new Spanned[numSaved];
    for (int a = 0; a < numSaved; a++)
    {
        EF =(Spanned) TextUtils.concat(EF, E[a]);
    }
    

    I also fixed my subscript issue by adding “small” tags.

    <sub><small>" + savedChem[g].getMoles() + "</small></sub>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use VBScript to loop through a set of registry string value
I need to be able to loop over only a section at a time
I need to be able to search through multiple 2D arrays and search the
I'm able to parse through the directory and list all images with any of
I'm using Ruby 1.9.2 and need to go through all of the values for
Users of the website need to able to store images in their area ,
Need to be able to pull Magento products into an external template. Need to
I need to be able to access a list throughout my Rails project. For
I need to be able to create an id for a hyperlink. I have
I need to be able to strip out a condition in a string, here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.