java - 在 onBindviewHolder 中使用不带循环的标签

标签 java android label

我正在尝试使用此代码:

@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/

相关文章:

Java react 堆 : How to produce Flux from stdin?

java - 双向链表中给定节点之间的反向链表 - 算法

android - 将 gif 图像发送到消息传递应用程序

android - Android手机可以使用windows DirectX库吗?

swift - 如何在快捷方式中使多个标签可单击?

Java - 将引号附加到数组中的字符串并连接数组中的字符串

java - android studio中如何使用按钮切换页面?

r - 将文本添加到绘图轴而不删除 r 中现有的轴标签

c# - 为什么不显示标签的内容?

java - 用Java读取GitHub项目的目录结构