所以我有以下 onCreate 函数
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mylocation = new MyLocation(this);
double distance = distance (mylocation.lat, mylocation.lng, messagelat, messagelong);
Log.d("Distance",Double.toString(distance));
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
mView = new SampleView(this,Double.toString(distance));
**this.setContentView(R.layout.activity_clouds);**
this.button = (Button)this.findViewById(R.id.close);
this.button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Activity1.this, CameraPreview.class);
Activity1.this.startActivity(myIntent);
}
});
**setContentView(mView);**
}
我的问题是我想同时使用来自 activity_cloud.xml 和 SampleView 的视图,但是如果我这样做,我只会得到示例视图!我想在 SampleView 类中添加一个按钮和覆盖层......非常感谢