通过F#获取xamarin.forms中的位置信息
Get location information in xamarin.forms by F #
- 现在我正在考虑为 android 制作一个应用程序并希望获取位置信息。
- 所以我决定使用xamarin的android sdk。
- 但我想使用字符串作为unit的参数,但我不确定这是否不可能
open System
open Android.App
open Android.Content
open Android.OS
open Android.Runtime
open Android.Views
open Android.Widget
open Android.Locations
type Resources = syutoku.Resource
[<Activity (Label = "syutoku", MainLauncher = true, Icon = "@mipmap/icon")>]
type MainActivity () =
inherit Activity ()
let L = ""
let mutable count:int = 1
let location = new Android.Locations.Location(L)
let lL = [L]
let soko = lL.[0]
override this.OnCreate (bundle) =
base.OnCreate (bundle)
// Set our view from the "main" layout resource
this.SetContentView (Resources.Layout.Main)
// Get our button from the layout resource, and attach an event to it
let button = this.FindViewById<Button>(Resources.Id.myButton)
button.Click.Add (fun args ->
button.Text <- sprintf "%d clicks!" count
count <- count + 1
)
let button_3 = this.FindViewById<Button>(Resources.Id.myButton3)
button_3.Click.Add (fun args ->
button_3.Text <- printfn "%s" soko
)
我在这里收到错误 FS0001。 ↑
我想你想使用 sprintf
而不是 printfn
,就像在前面的处理程序中一样:
button_3.Text <- sprintf "%s" soko
其中,由于 soko
是一个字符串,可以简化为:
button_3.Text <- soko
- 现在我正在考虑为 android 制作一个应用程序并希望获取位置信息。
- 所以我决定使用xamarin的android sdk。
- 但我想使用字符串作为unit的参数,但我不确定这是否不可能
open System
open Android.App
open Android.Content
open Android.OS
open Android.Runtime
open Android.Views
open Android.Widget
open Android.Locations
type Resources = syutoku.Resource
[<Activity (Label = "syutoku", MainLauncher = true, Icon = "@mipmap/icon")>]
type MainActivity () =
inherit Activity ()
let L = ""
let mutable count:int = 1
let location = new Android.Locations.Location(L)
let lL = [L]
let soko = lL.[0]
override this.OnCreate (bundle) =
base.OnCreate (bundle)
// Set our view from the "main" layout resource
this.SetContentView (Resources.Layout.Main)
// Get our button from the layout resource, and attach an event to it
let button = this.FindViewById<Button>(Resources.Id.myButton)
button.Click.Add (fun args ->
button.Text <- sprintf "%d clicks!" count
count <- count + 1
)
let button_3 = this.FindViewById<Button>(Resources.Id.myButton3)
button_3.Click.Add (fun args ->
button_3.Text <- printfn "%s" soko
)
我在这里收到错误 FS0001。 ↑
我想你想使用 sprintf
而不是 printfn
,就像在前面的处理程序中一样:
button_3.Text <- sprintf "%s" soko
其中,由于 soko
是一个字符串,可以简化为:
button_3.Text <- soko