java - Assign a double value to a TextView? -


how assign double value textview? code:

if(condition()) {      tv=(textview)view.findviewbyid(r.id.textview);      tv.settext(html.fromhtml("<b>text 01 </b>"));  } else {     tv=(textview)view.findviewbyid(r.id.textview);       tv.settext(html.fromhtml("<b>text 02</b>"));  }  if(condition) {     tv=(textview)view.findviewbyid(r.id.textview);       tv.settext(html.fromhtml("text 03"));  } else {     tv=(textview)view.findviewbyid(r.id.textview);       tv.settext(html.fromhtml("text 04"));  } 

if run application , both conditions true return visualize last written words text 03. how view text 01?

you using same textview. need create second textview or append string want.

    if(condition()) {          tv=(textview)view.findviewbyid(r.id.textview); // each time call reintializ                                                    // textview set new text                                                    // don't append text         tv.settext(html.fromhtml("<b>text 01 </b>"));     }     else {         tv=(textview)view.findviewbyid(r.id.textview);           tv.settext(html.fromhtml("<b>text 02</b>"));      }       if(condition) {         tv=(textview)view.findviewbyid(r.id.textview);           tv.settext(html.fromhtml("text 03"));      }     else {          tv=(textview)view.findviewbyid(r.id.textview);           tv.settext(html.fromhtml("text 04"));    } 

to make simpler initialize textview once , append text in second condition

tv=(textview)view.findviewbyid(r.id.textview); if (condition()) {     tv.settext(html.fromhtml("<b>text 01 </b>")); else {     tv.settext(html.fromhtml("<b>text 02</b>")); }  if (condition) {     tv.append(html.fromhtml("text 03")); } else {     tv.append(html.fromhtml("text 04")); } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -