简体   繁体   中英

Display data in text field on Android

How can I display the data obtained by the accelerometer in the EditText text box? It works just using 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);
}
EditText text = (EditText) findViewById(R.id.your_text);
text.setText("Display this text");
axex.setText(Float.toString(X+x+ms^2));

试试看。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM