我正在尝试在WPF中编写写字板(而不是记事本)。
public class MainActivity extends Activity implements LocationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);
this.onLocationChanged(null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public void onLocationChanged(Location location) {
TextView textView = (TextView) findViewById(R.id.textView);
if(location == null){textView.setText("--");}
else{textView.setText((int)location.getSpeed());}
}
}
我在使用它时遇到了问题。