我正在尝试使用此代码:
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
label :{
if(some condition) {
//my code
} else {
if(my condition) {
//some code
continue label; // from here i want to go back to label, how to i go?
}
}
}
}
行继续标签;给我这个错误:不是循环标签
所以我需要回到“标签”行我该怎么做?
最佳答案
为什么必须使用“标签”循环?
尝试使用 while 循环,如下所示:
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
while (true) {
if (some condition) {
// my code
break; // if this code ran then exit the while loop
} else if (my condition) {
// some code
continue; // from here it will make another iteration in the while loop
}
}
}
关于java - 在 onBindviewHolder 中使用不带循环的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35698996/