在Android上以文本字段显示数据

在Android上以文本字段显示数据,android,android-layout,sensormanager,Android,Android Layout,Sensormanager,如何在EditText文本框中显示加速计获得的数据? 它只需使用TextView public void onSensorChanged(SensorEvent event) { float x,y,z; x=event.values[0]; y=event.values[1]; z=event.values[2]; axex =(EditText)findViewById(R.id.editText1); axex.setText(X+x+ms^

如何在
EditText
文本框中显示加速计获得的数据? 它只需使用
TextView

public void onSensorChanged(SensorEvent event) {
    float x,y,z;
    x=event.values[0];
    y=event.values[1];
    z=event.values[2];
    axex =(EditText)findViewById(R.id.editText1);
    axex.setText(X+x+ms^2);
    axey=(EditText)findViewById(R.id.editText2);
    axey.setText(Y+y+ms^2);
    axez=(EditText)findViewById(R.id.editText3);
    axez.setText(Z+z+ms^2);
}

试试看。

如果这是一个编程问题,那么就缺少一个程序。正如斯尼科拉斯所写,你的问题不是一个真正的问题。你需要给出一些细节、错误和代码示例才能得到答案。我想在文本字段中显示加速计的结果,但它不起作用,这是一段代码:我想在文本字段中显示加速计的结果,但它不起作用,这是一段代码:public void onsensorchange(SensorEvent事件){float x,y,z;x=event.values[0];y=event.values[1];z=event.values[2];axex=(EditText)findViewById(R.id.editText1);axex.setText(x+x+ms^2);axey=(EditText)findViewById(R.id.editText2);axey=(y+y+y+ms^2)findViewById(R.id.editText3);axez.setText(Z+Z+ms^2);}}我没有收到任何错误,但应用程序在我知道的模拟器上不支持的模拟器传感器中不工作,您的问题是将数据设置为editText,这与模拟器或传感器的使用无关。您需要更清楚地回答您的问题。
EditText text = (EditText) findViewById(R.id.your_text);
text.setText("Display this text");
axex.setText(Float.toString(X+x+ms^2));