2

我正在构建一个基于位置的应用程序,它使用相机的图像而不是 2D 地图作为其用户界面。

在那个视图中,我想绘制一个可绘制的图像。当点之间的距离发生变化时,图像drawable也会发生变化。

一切正常,但仅限于第一个。当应该更改图像时,应用程序会挂起。但是相机拍摄的图像仍然是正常的方式。

这是我onCreate初始化drawable的代码:

arrow = (ImageView)findViewById(R.id.arah);
arrow.setVisibility(0);

res =  getResources();
lurus = res.getDrawable(R.drawable.arahlurus);
kanan = res.getDrawable(R.drawable.arahkanan);
kiri = res.getDrawable(R.drawable.arahkiri);
putar = res.getDrawable(R.drawable.arahputar);

这是我在方法 onLocationChanged() 中的代码:

arrow.setVisibility(0);
Location pointLocation = TEMP_LOCATION.get(check);
float distance = location.distanceTo(pointLocation);
int dist = (int)Math.round(distance);
//stepNext.setText("" + distance + " Meter");
//String chek = TEMP_POINT.get(check).toString();;
if (dist / 4 == 0){
    stepNext.setText("" + dist + "meter");
    Toast.makeText(ARrazerNav.this, "Jarak Dengan Checkpoint: " +dist, Toast.LENGTH_SHORT).show();
}
else if (dist < 15){
    arrow.setVisibility(0);
    //speakWords(TEMP_NAME.get(check).toString());
    check++;
}
else if (dist >= 10 && dist <= 27){
    arrow.setVisibility(1);
    if(checkOrientation == 1){
        if (TEMP_POINT.get(check) == 1){
            arrow.setImageDrawable(lurus);
        }
        else if (TEMP_POINT.get(check) == 2){
            arrow.setImageDrawable(kanan);
        }
        else if(TEMP_POINT.get(check) == 3){
            arrow.setImageDrawable(putar);
        }
        else{
            arrow.setImageDrawable(kiri);
        }
    }else{
        if (TEMP_POINT.get(check) == 1){
            arrow.setImageDrawable(kiri);
        }
        else if (TEMP_POINT.get(check) == 2){
            arrow.setImageDrawable(lurus);
        }
        else if(TEMP_POINT.get(check) == 3){
            arrow.setImageDrawable(kanan);
        }
        else{
            arrow.setImageDrawable(putar);
        }
    }
}
4

0 回答 0