我想一个网页加载到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应用程序 –