2013-05-08 85 views
1

我爲一個(UnityPlayer)活動添加了一個Web視圖,但是webview沒有接收到觸摸。安卓視圖不能接收觸摸

由於加載時間,我無法將webview添加到新的活動。所以我即時從當前活動獲取根視圖並添加一個包含webview的新佈局。很明顯,應用程序中的某些東西是阻止我的webview接受觸摸。任何想法如何確保webview接受接觸。

UnityPlayer.currentActivity.runOnUiThread(new Runnable() { 
    public void run() { 
     FrameLayout layout = new FrameLayout(UnityPlayer.currentActivity); 
     WebView webview = new WebView(UnityPlayer.currentActivity); 
     webview.loadUrl(url); 
     ViewGroup rootView = (ViewGroup)(UnityPlayer.currentActivity.getWindow().getDecorView().findViewById(android.R.id.content)); 
     rootView.addView(layout); 
     layout.addView(webview); 
    } 
}); 

請注意:我沒有獲得UntiyPlayer.currentActivity源

乾杯大家

+0

[我如何可以在android的webview上獲取onclick事件?](http://stackoverflow.com /問題/ 5116909 /如何我可以得到onclick事件在webview在Android) – Snicolas 2013-05-08 07:49:38

+0

沒有它的一個不同的問題。如果我創建了一個新的活動並將該webview添加到該活動中,而不是webview接受涉及的問題。但是,如果我將webview添加到UnityPlayer.currentActivity,那麼該活動中的某些內容會阻止Webview接受觸摸。所以這個問題不在webview中,它與停止觸摸的觀點有關。 – user346443 2013-05-08 07:56:44

回答

3

我需要添加

<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> 

到活動中manefest

+0

你能提供更多的細節嗎?我使用插件https://github.com/gree/unity-webview。 AndroidManifest在它的示例代碼中有,但是在這個網站上https://minecraft.net/login我不能在textfields中做任何輸入。 – Petr 2013-07-09 08:51:06