如何解决通过 F# 获取 xamarin.forms 中的位置信息
- 现在我正在考虑为 android 开发一个应用程序并想要获取位置信息。
- 所以我决定使用 xamarin 的 android sdk。
- 但我想使用字符串作为单元的参数,但我不确定这是不可能的还是可能的
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。