2012-04-26 44 views
0

如何在EditText文本框中顯示由加速度計獲取的數據? 它只是使用TextView在Android上的文本字段中顯示數據

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); 
} 
+2

如果這是一個編程問題,那麼程序就會丟失。 – Snicolas 2012-04-26 19:52:33

回答

1
EditText text = (EditText) findViewById(R.id.your_text); 
text.setText("Display this text"); 
+0

TKS 我嘗試,但它不工作:( – bella 2012-04-26 20:03:43

+0

爲Snicolas寫道,你的問題是不是一個真正的問題。你需要給一些細節,錯誤代碼示例,以得到答案。 – 2012-04-26 20:05:49

+0

我想要顯示的結果在文本字段中的加速度計,但它沒有工作,這是一段代碼: – bella 2012-04-26 20:18:21

0
axex.setText(Float.toString(X+x+ms^2)); 

嘗試。

相關問題