从c#android应用程序加载网页 [英] loading a webpage from a c# android app

查看:61
本文介绍了从c#android应用程序加载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试使用xamarin和c#制作一个Android应用程序我尝试了很多不同的东西我只是想弄清楚如何让网页打开我到目前为止已经这样了



Hi i am trying to make an android app using xamarin and c# I have tried so many different things I just cant figure out how to get the webpage to open i have this so far

01
using System;
02
using Android.App;
03
using Android.Content;
04
using Android.Runtime;
05
using Android.Views;
06
using Android.Widget;
07
using Android.OS;
08
using Android.Webkit;
09
using Android.Net;
10
 
11
 
12
namespace llll
13
{
14
    [Activity (Label = "llll", MainLauncher = true)]
15
    public class MainActivity : Activity
16
    {
17
        string target = "http://www.wealdstonefc.co.uk/";
18
        protected override void OnCreate (Bundle bundle)
19
        {
20
            base.OnCreate (bundle);
21
 
22
            LinearLayout layout = new LinearLayout (this);
23
            layout.Orientation = Orientation.Vertical;
24
 
25
            TextView label = new TextView (this);
26
            label.Text = "Wealdstone";
27
 
28
            Button button = new Button (this);
29
            button.Text = "League Table";
30
 
31
            button.Click += (object sender, EventArgs e) => {
32
 
33
             
34
                StartActivity (new Intent (Intent.ActionView, Uri.parse("http://www.wealdstonefc.co.uk/")));
35
 
36
            };
37
        }
38
        }
39
    }





非常感谢任何帮助



i认为整行StartActivity(新的Intent(Intent.ActionView,Uri.parse(http://www.wealdstonefc.co.uk/))) ;是不对的,因为我不断收到错误



- C:\ Users \ Moonie \Documents \Projects \ allll \ allll \ MainActivity.cs( 51,51):错误CS0104:'Uri'是'System.Uri'和'Android.Net.Uri'之间的模糊引用(CS0104)(llll)

- C:\ Users \\ \\ Moonie \Documents\Projects \llll \ allll \ MainActivity.cs(55,55):错误CS0117:'System.Uri'不包含'parse'的定义(CS0117)(llll)



any help is greatly appreciated

i think the whole line StartActivity (new Intent (Intent.ActionView, Uri.parse("http://www.wealdstonefc.co.uk/"))); is wrong as i keep getting errors

- C:\Users\Moonie\Documents\Projects\llll\llll\MainActivity.cs(51,51): Error CS0104: 'Uri' is an ambiguous reference between 'System.Uri' and 'Android.Net.Uri' (CS0104) (llll)
- C:\Users\Moonie\Documents\Projects\llll\llll\MainActivity.cs(55,55): Error CS0117: 'System.Uri' does not contain a definition for 'parse' (CS0117) (llll)

推荐答案

在第34行,您应首先指明您的意思 Android.Net.Uri ,而不是 System.Uri ,然后你应该大写 Parse

At line 34, you should first specify that you mean Android.Net.Uri, and not System.Uri, and then you should capitalize Parse:
StartActivity (new Intent (Intent.ActionView, Android.Net.Uri.Parse("http://www.wealdstonefc.co.uk/")));


非常感谢,我只是检查我是否有所需的结果
Thank you so much, im just checking to see if i have the desired results


这篇关于从c#android应用程序加载网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆