我想在{N}
中使用ArrayList forEach怎么样?帮我们! PLZ。
Java代码
public boolean OnPressEvent(ArrayList<MarkerItem> markers){
// in code
}
{N}的代码
onPressEvent: function(markers: MarkerItem[]) {
// in code (for android)
console.log("length", markers.length) // = undefined
console.log("length", markers.size()) // = 0~n (integer)
// i want run below codes.
markers.forEach(function(marker){
// marker editing....
});
}
答案 0 :(得分:4)
最简单的方法是:
onPressEvent: function(markers: MarkerItem[]) {
var size = markers.size();
for (var i=0;i<size;i++) {
var aMarker = markers.get(i);
// Do whatever I need to do with this item
}
});