1

我正在尝试实现一个 Android 应用程序,在主要活动中它显示的是谷歌地图,并且我也在尝试在相同的布局上实现一个视频视图。因此,在主地图活动(显示地图时)中,我试图实现一个线程,该线程将同时调用地图视图下方的视频视图活动(进行录制)。

这可能吗 ?因为我遇到了很多错误。请任何人都可以帮助我..?谢谢

公共类 MainActivity 扩展 MapActivity 实现 Runnable{

private MapView mapView;
private MyLocationOverlay myLocationOverlay;
private Button playerbtn;//button to start player
private Button recorderbtn;//button for recorder
private VideoView mVideoView;
private Uri mVideoUri;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mVideoView = (VideoView) findViewById(R.id.videoview);
    playerbtn= (Button)findViewById(R.id.playback);
    recorderbtn = (Button)findViewById(R.id.recording);

    // main.xml contains a MapView
    setContentView(R.layout.main); 

    // extract MapView from layout
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    // create an overlay that shows our current location
    myLocationOverlay = new FixedMyLocationOverlay(this, mapView);

    // add this overlay to the MapView and refresh it
    mapView.getOverlays().add(myLocationOverlay);
    mapView.postInvalidate();

    // call convenience method that zooms map on our location
    zoomToMyLocation();



}

//--videoview

public void recordingListner(View view) {

    Thread toRun = new Thread()
       {
              public void run()
              {

                 final Intent intent = new Intent(MainActivity.this, VideoRecorder.class);
                handleCameraVideo(intent);
                startActivity(intent);    

              }
       };
       toRun.start(); 

}

private void handleCameraVideo(Intent intent) {
    mVideoUri = intent.getData();
    mVideoView.setVideoURI(mVideoUri);
    mVideoView.setVisibility(View.VISIBLE);
}
4

1 回答 1

0

将您setContentView(R.layout.main);移到右侧super.onCreate(savedInstanceState);。在调用 findViewById 之前,您必须调用 setContentView。

于 2012-10-28T14:01:57.393 回答