My problem is just the decimal number format. I am a beginner and I do not know how to resolve the problem. I think I should use decimal format, but I do not know how to use it.
And here is my java code:
public class MainActivity extends Activity implements SensorEventListener {
@Override
public void onSensorChanged(SensorEvent event) {
// get the angle around the z-axis rotated
float degree = event.values[0];
tvHeading.setText(Float.toString(degree) + "°");
// create a rotation animation (reverse turn degree degrees)
RotateAnimation ra = new RotateAnimation(
currentDegree, -degree,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
// how long the animation will take place
ra.setDuration(210);
// set the animation after the end of the reservation status
ra.setFillAfter(true);
// Start the animation
image.startAnimation(ra);
currentDegree = -degree;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// not in use
}
}