我想得到屏幕的压力.生病时,应用程序向我显示一条消息,Unfortunately, Application has stopped.我有另一个问题,当生病得到屏幕的压力可以转换成一个数学或物理的重量(克)?这是我的代码:
编辑:我在平板电脑上运行此应用程序
package com.realscale.stefanrafa;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView textinfo;
MotionEvent pressure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textinfo = (TextView) findViewById(R.id.Information);
float press = pressure.getPressure();
textinfo.setText("Scale: " + (int) press);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} …Run Code Online (Sandbox Code Playgroud)