我想一個網頁加載到xamarin應用我mainactivity.cs頁面有以下代碼xamarin加載網頁
public class MainActivity : Activity
{
WebView webView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
webView = FindViewById<WebView>(Resource.Id.webView);
webView.LoadUrl("https://urlofwebpage");
WebSettings webSettings = webView.Settings;
webSettings.JavaScriptEnabled = true;
}
}
和我main.axml包含此
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.webkit.WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView" />
</LinearLayout>
它似乎建立,但我只有在模擬器中得到一個黑屏
任何人都可以闡明爲什麼?
你在模擬器中使用什麼設備?試用手機,如果試圖與平板電腦 –
這是一個Android應用程序 –