我是 Java 和 Android 编程语言的新手,这是我研究的第一个平台。我想问一下,这个方法怎么访问event.values[1]?
public void onSensorChanged(SensorEvent event) {synchronized (this){
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
return;
mAccVals.x = (float) (event.values[1] * FILTERING_FACTOR + mAccVals.x * (1.0 - FILTERING_FACTOR));
//mAccVals.y = (float) ((-event.values[1] * FILTERING_FACTOR + mAccVals.y * (1.0 - FILTERING_FACTOR)));
mAccVals.z = (float) (event.values[2] * FILTERING_FACTOR + mAccVals.z * (1.0 - FILTERING_FACTOR));
scene.camera().position.x = mAccVals.x * .2f;
scene.camera().position.z = mAccVals.z * .8f;
scene.camera().target.x = -scene.camera().position.x;
scene.camera().target.z = -scene.camera().position.z;
}
我想获取 event.values[1] 然后在 textview 上显示它
protected void onCreateSetContentView()
{
setContentView(R.layout.custom_layout_example);
LinearLayout ll = (LinearLayout) this.findViewById(R.id.scene1Holder);
ll.addView(_glSurfaceView);
TextView myTextView = (TextView) findViewById(R.id.splashTitle);
myTextView.setText("Test " + event.values[1] );
return;
}
有什么建议我该如何解决这个问题?提前致谢