[英]Get location information in xamarin.forms by F #
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.