안드로이드 개발 질문/답변
(글 수 45,052)
질문 .1
제가 특정 gps 값 들어오면 이미지가 뜨게 하는 작업을 하고 있습니다 @Override
public void onLocationChanged(Location location)
{
LatiValue = location.getLatitude();
LongiValue = location.getLongitude();
if(LatiValue == 126 && LongiValue == 37)
{
da.setFlag(1);
}
}
'
'
'
'
생략!!
.
.
public class DrawAllow extends View
{
int flag;
Bitmap arrow;
Bitmap resize1;
public DrawAllow(Context context)
{
super(context);
}
public int getFlag()
{
return flag;
}
public void setFlag(int f)
{
flag = f;
}
@Override
protected void onDraw(Canvas canvas)
{
int a = flag;
if(a == 0)
{
Paint pnt = new Paint();
arrow = BitmapFactory.decodeResource(this.getResources(), R.drawable.allow);
resize1 = Bitmap.createScaledBitmap(arrow, 250, 60, true);
pnt.setAlpha(200);
canvas.drawBitmap(resize1, 120, 205, pnt);
}
else if(a == 1)
{
Paint pnt = new Paint();
Resources r = getResources();
Bitmap arrow = BitmapFactory.decodeResource(this.getResources(), R.drawable.leftturn);
Bitmap resize = Bitmap.createScaledBitmap(arrow, 180, 40, true);
pnt.setAlpha(200);
canvas.drawBitmap(resize, 155, 160, pnt);
}
}
이런식으로 flag 값 비교해서 이미지를 띄우는데
문제는 저위
@Override
public void onLocationChanged(Location location)
에서 if 만 사용할때는 이미지가 해당 gps 값을 보내줄때마다 잘 뜹니다
하지만 !!!
@Override
public void onLocationChanged(Location location)
{
LatiValue = location.getLatitude();
LongiValue = location.getLongitude();
if(LatiValue == 126 && LongiValue == 37)
{
da.setFlag(1);
}
else
{
da.setFlag(0);
}
}
이렇게 else 문을 넣어줬는데
위아래 모두 이미지가 떠오르지 않습니다
위 오버라이드 함수들의 호출 시점떄문인지 아니면 코드상 문제인지 궁금합니다..ㅜ.ㅜ