変数「azimuth_angle」があります
画面をタッチして方向を変えるといいですね
変数「azimuth_angle」が減少します
私のコードで
画面に触れると変数が減少します
しかし、それがうまくいかない方向を変える
同じinvalidate()を使用します
これの何が悪いの??
public class HelloCamera extends Activity implements SensorEventListener
{
private MyView mView;
float azimuth_angle = 365;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mView = new MyView(this);
setContentView(new HelloCameraPreview(this));
addContentView(mView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
private class MyView extends View
{
private Paint mPaint;
public MyView(Context context)
{
super(context);
mPaint = new Paint();
mPaint.setColor(Color.YELLOW);
mPaint.setTextSize(12);
}
public void onDraw(Canvas canvas)
{
float x = 10;
float y = 20;
canvas.drawText(String.valueOf(azimuth_angle), x, y, mPaint );
azimuth_angle--;
}
public boolean onTouchEvent(MotionEvent event)
{
invalidate();//But this can work
return true;
}
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if(event.sensor.getType() == Sensor.TYPE_ORIENTATION)
{
azimuth_angle = event.values[0];
mView.invalidate();//it doesnt work
}
}
}