Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Xamarin Webview不会启动新选项卡_Android_Xamarin_Webview - Fatal编程技术网

Android Xamarin Webview不会启动新选项卡

Android Xamarin Webview不会启动新选项卡,android,xamarin,webview,Android,Xamarin,Webview,我在玩xamarin android webview时遇到了这个问题。webview不会打开设置为在“新建”选项卡中打开的页面。例如,stackoverflow上的招聘广告设置为在新选项卡中打开,当您触摸它们时,什么也不会发生!。提前谢谢,这是我的代码 [Activity(MainLauncher = false, Theme = "@android:style/Theme.NoTitleBar")] public class Obs_Activity : Activity { Web

我在玩xamarin android webview时遇到了这个问题。webview不会打开设置为在“新建”选项卡中打开的页面。例如,stackoverflow上的招聘广告设置为在新选项卡中打开,当您触摸它们时,什么也不会发生!。提前谢谢,这是我的代码

 [Activity(MainLauncher = false, Theme = "@android:style/Theme.NoTitleBar")]
public class Obs_Activity : Activity
{
    WebView web_view;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.sist);
        web_view = FindViewById<WebView>(Resource.Id.webview);
        web_view.Settings.SetSupportMultipleWindows(false);
        web_view.Settings.UseWebViewBackgroundForOverscrollBackground = true;
        web_view.Settings.PluginsEnabled = true;
        web_view.Settings.AllowFileAccess = true;
        web_view.Settings.DisplayZoomControls = true;
        web_view.SetWebViewClient(new HelloWebViewClient(this));


        web_view.Settings.JavaScriptEnabled = true;
        web_view.Settings.JavaScriptCanOpenWindowsAutomatically = true;
        web_view.Settings.SetSupportZoom(true);
        web_view.LoadUrl("http://obs.kku.edu.tr/");
    }




}
public class HelloWebViewClient : WebViewClient
{
    public Activity mActivity;
    public HelloWebViewClient(Activity mActivity)
    {
        this.mActivity = mActivity;
    }
    public override bool ShouldOverrideUrlLoading(WebView view, string url)
    {
        view.LoadUrl(url);
        Toast.MakeText(mActivity, "Yukleniyor...",
                             ToastLength.Long).Show();
        return true;
    }

    public override void OnReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, string host, string realm)
    {
        base.OnReceivedHttpAuthRequest(view, handler, host, realm);
        Toast.MakeText(mActivity, "Hata", ToastLength.Long).Show();
    }
}
[活动(MainLauncher=false,Theme=“@android:style/Theme.NoTitleBar”)]
公开课Obs_活动:活动
{
网络视图网络视图;
创建时受保护的覆盖无效(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.sist);
web_view=findviewbyd(Resource.Id.webview);
web_view.Settings.SetSupportMultipleWindows(false);
web_view.Settings.UseWebViewBackgroundForOverscrollBackground=true;
web_view.Settings.PluginsEnabled=true;
web_view.Settings.AllowFileAccess=true;
web_view.Settings.DisplayZoomControl=true;
SetWebViewClient(新HelloWebViewClient(this));
web_view.Settings.JavaScriptEnabled=true;
web_view.Settings.JavaScriptCanOpenWindowsAutomatically=true;
web_view.Settings.SetSupportZoom(true);
web_view.LoadUrl(“http://obs.kku.edu.tr/");
}
}
公共类HelloWebViewClient:WebViewClient
{
公共活动积极性;
公共HelloWebViewClient(活动权限)
{
this.mActivity=mActivity;
}
公共重写bool ShouldOverrideUrlLoading(WebView视图,字符串url)
{
view.LoadUrl(url);
Toast.MakeText(mActivity,“Yukleniyor…”,
ToastLength.Long)Show();
返回true;
}
公共重写void onReceiveDhtPauthRequest(WebView视图、HttpAuthHandler处理程序、字符串主机、字符串域)
{
OnReceivedHttpAuthRequest(视图、处理程序、主机、领域);
MakeText(mActivity,“Hata”,ToastLength.Long).Show();
}
}
01-23 13:02:36.695 D/WebViewCallback(16789):应该交互请求= 01-23 13:02:36.711 D/WebViewCallback(16789):onLoadResource= 01-23 13:02:36.712 D/WebViewCallback(16789):doUpdateVisitedHistory=reload=false 01-23 13:02:36.740 D/WebViewCallback(16789):onPageFinished,url=

这是我按下该链接时的日志,但什么也没有发生。

WebView不支持选项卡如果您想要一个选项卡式浏览器UI,您需要自己实现它

您正在将
setSupportMultipleWidows
设置为
true
,但没有实现
WebChromeClient
,它是
OnCreateWindow
方法

设置WebView是否支持多个窗口。如果设置为true,主机应用程序必须实现onCreateWindow(WebView、boolean、boolean、Message)

  • 如果希望
    Apply Now
    /JavaScript弹出窗口出现在新页面中,请继续使用
    WebViewClient
    ,但将
    SetSupportMultipleWindows
    设置为
    false

  • 如果要在选项卡中打开新的
    WebView
    ,则需要实现
    WebChromeClient
    子类,并覆盖
    OnWindowCreate
    并通过
    WebView.SetWebChromeClient
    进行设置,否则该链接将在默认的|系统web浏览器中打开


可能重复的不,它甚至还没有关闭。我不想要选项卡式浏览器,我只想在同一网络视图中显示新选项卡,因为它们不是新选项卡。我将SetSupportMultipleWidows设置为false,但当您单击设置为“新建选项卡”的某个链接时,什么都不会发生。好的,新选项卡很好,正如我在webview上所希望的那样。浏览器将阻止新选项卡。我想这就是问题所在。编辑了主要帖子。我将setJavaScriptCanOpenWindowsAutomatically设置为true。现在将打开一个新的空白页。为什么它是空白的,奇怪的当你点击谷歌浏览器上的链接时,它说谷歌浏览器阻止了一个弹出窗口。我认为这就是问题所在here@M.Han将
setSupportMultipleWidows
设置为false如果您没有实现
WebChromeClient
,它将在新页面中打开(在my
WebView
上)。