Java - Android studio -


how output of lt.gettest02() which either 1, 2, or 3 display 'word' on screen each output. example if output 1, display "left" instead of number '1'.....if output 2 display "centre" , if output 3, display "right". tried couple of methods couldn't it. think need function it.

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_back_to_main);     textview = (textview) findviewbyid(r.id.textviewbacktomain);     databasehandler db = mainactivity.db;     lt = mainactivity.linetest;     //results   string textoutput = "id: " + lt.getid() + " ,patientid: " + lt.getpatientid() + " ,timestamp: " + lt.gettimestamp()                  + "\n\n test02: " + lt.gettest02()                  + "\n test05: " + lt.gettest05()                  + "\n test07: " + lt.gettest07()                 + "\n test08: " + lt.gettest08()                 + "\n test09: " + lt.gettest09()                  + "\n test11: " + lt.gettest11()                  + "\n test13: " + lt.gettest13()                  + "\n test16: " + lt.gettest16()                 + "\n test17: " + lt.gettest17()                 + "\n test18: " + lt.gettest18()                  + "\n test22: " + lt.gettest22()                  + "\n test25: " + lt.gettest25()                  + "\n test27: " + lt.gettest27()                 + "\n test28: " + lt.gettest28()                 + "\n test29: " + lt.gettest29()                  + "\n test31: " + lt.gettest31()                  + "\n test33: " + lt.gettest33()                  + "\n test36: " + lt.gettest36()                 + "\n test37: " + lt.gettest37()                 + "\n test38: " + lt.gettest38()          ;          //displays on screen         textview.settext(textoutput);  onclickbuttonlistener(); } 

following comment can use following helper function:

string helper(string index) {    if(index.equals("1")) return "left";    if(index.equals("2")) return "right";    if(index.equals("3")) return "centre";    return ""; } 

and replace following line:

+ "\n\n test02: " + lt.gettest02() 

with

+ "\n\n test02: " + helper(lt.gettest02()) 

Comments