java - Iterate over click listeners on a button -


i have imageview i've assigned click listener. i'm trying figure out how give listener new function depending on user in loop. example, first click show textview, second click show another, , third click hide both.

public void addoption(view view) {         int index = 2;          switch (index) {             case 0:                 // if using index 0, set text index 1 text , change index 1                 index = 1;                 findviewbyid(r.id.polloption3textinputlayout).setvisibility(view.visible);                 break;             case 1:                 index = 2;                 findviewbyid(r.id.polloption4textinputlayout).setvisibility(view.visible);                 break;             case 2:                 index = 0;                 findviewbyid(r.id.polloption3textinputlayout).setvisibility(view.gone);                 findviewbyid(r.id.polloption4textinputlayout).setvisibility(view.gone);                 break;         }     } 

how can go doing this?

keep index outside method (simplest way):

int index = 0; public void addoption(view view) {     switch (index) {         ... 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -