I’m trying to get it so that when the user clicks popbtnnext within the popup, the program checks if the rest of the array flaggedwordsused is null. If not, the button is set to be visible and the program moves on. If it is null, the program updates the button to be invisible.
popbutnext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
f++;
for (int g= f+1; g<flagwordsused.length; g++) {
if (flagwordsused[g] != null) {
popbutnext.setVisibility(0);
break;
}
else{
poptv1.setText(""+f);
popbutnext.setVisibility(1);
}
}
}
});
flagwordsused is an array of 20 elements, f in my test case starts at 0 with the string “very” occupying element zero and all other values are null. I have a textView updating with values of f so that I know the program is getting to the else statement. That value is updating just fine but the visibility of the button never changes. Any help you could give me would be appreciated. The popuplayout was created in java, not xml if that makes any difference.
You should use the constants in View to set visibility instead. Makes the code easier to read too:
To make popbutnext invisible:
To make popbutnext invisible and not take any space when building the layout:
To make popbutnext visible:
The reason that it does not work for you is because the values are wrong. Invisible is 4, gone is 8, visible is 0. However, I still recommend to use the constants in the View class – you never know, they might change in coming Android versions. Take a look at this link, and the visibility parameter.