0
我正在嘗試製作一個統一的android插件。無法創建SurfaceView
我有手動啓動這樣一個活動:
Activity activity = UnityPlayer.currentActivity;
Intent intent = new Intent(activity, VideoHelper.class);
activity.startActivity(intent);
在我嘗試創建一個SurfaceView的活動,但它不工作。 SurfaceView不會被創建。
活動:
public class VideoHelper extends Activity implements SurfaceHolder.Callback, OnCompletionListener
{
@Override
public void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setContentView(R.layout.video_layout);
View view = findViewById(R.id.videoView);
if(view == null)
{
Log.d(LibraryMain.LogTag, "Could not create view");
}
else
{
Log.d(LibraryMain.LogTag, "View created");
}
//SurfaceHolder holder = view.getHolder();
//holder.addCallback(this);
}
...
}
video_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SurfaceView android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/videoView"></SurfaceView>
</LinearLayout>
我總是到日誌中無法創建視圖。 我做錯了什麼?或者有沒有辦法通過代碼創建surfaceView?
請張貼使用的LinearLayout嘗試創建只是SurfaceView的日誌instand(更換SurfaceView的LinearLayout中,取下方向 –
沒有幫助,我改變了佈局XML這樣:<?XML版本=「1.0 「encoding =」utf-8「?> SurfaceView> –
Sobraj