thevoipman
thevoipman

Reputation: 1833

Android elseif else won't process correctly

extreme noob here, i'm trying to export statements not strings within my if else statement. some how it's not working, please help.

        if(number==0) { canvas.drawColor(Color.rgb(123, 214, 217)); } 
    elseif(number==1) { canvas.drawColor(Color.rgb(121, 214, 217)); } 
    else {  canvas.drawColor(Color.rgb(54, 214, 217));  }

Upvotes: 0

Views: 68

Answers (3)

user4774371
user4774371

Reputation:

Replace

 if(number==0) { canvas.drawColor(Color.rgb(123, 214, 217)); } 
    elseif(number==1) { canvas.drawColor(Color.rgb(121, 214, 217)); } 
    else {  canvas.drawColor(Color.rgb(54, 214, 217));  }

with

 if(number==0) {
     canvas.drawColor(Color.rgb(123, 214, 217));
 } else if(number==1) { 
     canvas.drawColor(Color.rgb(121, 214, 217)); 
 } else {  
     canvas.drawColor(Color.rgb(54, 214, 217)); 
 }

Always indent your code. I wonder why, your IDE is not showing you syntax error

Upvotes: 1

Shailendra Madda
Shailendra Madda

Reputation: 21551

Replace this

if(number==0) { canvas.drawColor(Color.rgb(123, 214, 217)); } 
    elseif(number==1) { canvas.drawColor(Color.rgb(121, 214, 217)); } 
    else {  canvas.drawColor(Color.rgb(54, 214, 217));  }

with this:

if(number==0) { canvas.drawColor(Color.rgb(123, 214, 217)); } 
    else if(number==1) { canvas.drawColor(Color.rgb(121, 214, 217)); } 
    else {  canvas.drawColor(Color.rgb(54, 214, 217));  }

Upvotes: 1

Patrick Roberts
Patrick Roberts

Reputation: 51936

In JavaScript, the syntax is else if, not elseif.

Upvotes: 5

Related Questions