2016-05-31 50 views
0

爲了使用紙板視頻(CardboardView),我必須擴展CardboardActivity。 [糾正我,如果我錯了]。如何擴展CardboardActivity和ActionBarActivity

但是,如果我想用我的Activity來擴展ActionBarActivity,那麼如何在ActionBarActivity中顯示CardboardView呢?

+0

在github上試試這個示例代碼... https://github.com/raasun/cardboard –

回答

0

如果您想使用紙板視圖,您可以在活動和片段中實現該視圖。沒有必要延伸紙板活動

使用VRVideoView

XML:

<com.google.vrtoolkit.cardboard.widgets.video.VrVideoView 
     android:id="@+id/video_view" 
     android:layout_width="match_parent" 
     android:scrollbars="@null" 
     android:layout_height="250dip"/> 

機器人:

private VrVideoView videoWidgetView; 

videoWidgetView = (VrVideoView) findViewById(R.id.video_view); 
videoWidgetView.setEventListener(new ActivityEventListener()); 
videoWidgetView.loadVideoFromAsset("congo.mp4"); 

private class ActivityEventListener extends VrVideoEventListener { 



@Override 
public void onLoadSuccess() { 

} 


@Override 
public void onLoadError() { 

} 

@Override 
public void onClick() { 
} 


@Override 
public void onNewFrame() { 

} 

@Override 
public void onCompletion() { 

} 
} 

這是視頻視圖的主代碼。使用此代碼供您參考。 參考link,嘗試this

注: 使用紙板活動是根據您的要求。

一些例子:如果你想使用磁性觸發在谷歌紙板,你需要擴展紙板活動

閱讀本文too

相關問題