尝试更改图像drawable时应用程序冻结

时间:2012-06-26 16:53:44

标签: android android-layout android-intent

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

在该视图中,我想绘制一个可绘制的图像。当点之间的距离改变时,图像可绘制也会改变。

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

这是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);
        }
    }
}

0 个答案:

没有答案