大佬教程收集整理的这篇文章主要介绍了Xamarin / Android:F#范围 – 如何在不同的文件中看到命名空间?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这听起来很基本,但我似乎无法让它发挥作用.我将举例说明:
我开始一个新的解决方案,我选择一个新的F#Android应用程序并将其称为FSScopeTest1,给我MainActivity.fs
namespace FSScopeTest1 open System open Android.Content open Android.oS open Android.Runtime open Android.Views open Adroid.Widget [<Activity (Label = "FSScopeTest1",MainLauncher = truE)>] type MainActivity () = inherit Activity () let mutable count:int = 1 override this.OnCreate (bundlE) = base.onCreate (bundlE) // Set our view from the "main" layout resource this.SetContentView (resource_Layout.Main) // Get our button from the layout resource,and attach an event to it let button = this.FindViewById<Button>(resource_id.myButton) button.Click.Add (fun args -> button.Text <- sprintf "%d clicks" count count <- count + 1 )
namespace ScopeTestNS module ScopeTestMod = let astr = "some text"
然后我在第二行添加到MainActivity.fs:
open ScopeTestNS
并更改button.Click.Add的lamba表达式以进行读取
button.Click.Add (fun args -> // button.Text <- sprintf "%d clicks!" count // count <- count + 1 button.Text <- ScopeTestMod.astr )
The namespace or module "ScopeTestMod" is not defined.
如何使我的命名空间ScopeTestNS在MainActivity.fs中可见,这样我可以看到我在那里定义的任何模块?
非常感谢,
罗斯
根据Onorio Catenacci的评论编辑:
显然,Xamarin studio中使用的F#绑定目前不支持重新排序F#项目中的文件(请参阅此github问题https://github.com/fsharp/fsharpbinding/issues/135).但是,.fsproj文件是简单的xml文件,可以使用文本编辑器进行编辑,以更改编译文件的顺序.
编辑编辑
显然,xamarin工作室中的F#addin现在允许拖放以重新排序文件(感谢@ 7sharp9进行更新)
以上是大佬教程为你收集整理的Xamarin / Android:F#范围 – 如何在不同的文件中看到命名空间?全部内容,希望文章能够帮你解决Xamarin / Android:F#范围 – 如何在不同的文件中看到命名空间?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。