[英]Java: Anonymous new View.OnClickListener() can be replaced with lambda
Can anyone help me with this error谁能帮我解决这个错误
Anonymous new View.OnClickListener() can be replaced with lambda
匿名 new View.OnClickListener() 可以替换为 lambda
button_copy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String scanned_text = textview_data.getText().toString();
copyToClipBoard(scanned_text);
}
});
Can anyone help me with this error
谁能帮我解决这个错误
As noted in the comments it is NOT an error.如评论中所述,这不是错误。 It is style advice provided by your IDE (I guess).
这是您的 IDE 提供的样式建议(我猜)。
You could ignore it, and there are probably IDE-specific settings to selectively turn off this kind of message.您可以忽略它,并且可能有特定于 IDE 的设置可以选择性地关闭此类消息。 But it is easy to just follow the IDE's suggestion and replace the anonymous class with a lambda;
但是很容易按照 IDE 的建议将匿名类替换为 lambda; eg
例如
button_copy.setOnClickListener(
v -> copyToClipBoard(textview_data.getText().toString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.