我想在适当的最小整数值时做一些说明。例如:当变量“round_min”= 10 - >有一些指令。当“round_min”= 100时 - >有另一条指令。HashMap:它在TextView中显示最小值,但min_variable有更多值
我试着实现在HashMap中找到最小值的函数。 例如:我在HashMap中有两个元素。并且找到最小值,并且正确显示在TextView中。
但是,当我想要使用这个变量“round_min”到另一个函数时,在hashmap中显示了所有的值。我想始终保持最低限度。
下面我将介绍代码:
int round_min;
// nearestDistances is a hashmap where I put distances
Map.Entry<String, Float> nearestMarker = null;
for (Map.Entry<String, Float> entry : nearestDistances.entrySet()) {
if (nearestMarker == null || nearestMarker.getValue() > entry.getValue()) {
nearestMarker = entry;
round_min = Math.round(nearestMarker.getValue());
Log.e(" MIN ", round_min + "");
// it displays in log.e all values
// this function see all values, not only minimum
DisplayMinimumValue(getApplicationContext(), round_min);
Log.e(" ROUND MIN ", round_min + "");
tvDistanceToNearest.setText(String.valueOf(round_min)); // there is displaying only minimum value
}
}
有人能帮助我找到的问题,以及如何用它弄清楚?
谢谢。有用 :) – gryzek