Search code examples
xmlandroid-activityf#setcontentview

Inherit XML interface / set activity / setView


I want to learn more about phone app programming. But i want to learn it via F#.

In Java you can inherit an XML interface like this:

public class DanishRegisterSite extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register_denmark_ui);

    }

}

The guides on this subject regarding F# are very few. So i hope someone here can tell me how would i go about setting the content view of an xml document like above but in F# ?

Thx


Solution

  • This will set the view of your F# based phone android App

    namespace setView 
    
        // library adding
        open System 
        open Android.App
        open Android.Content
        open Android.OS
        open Android.Runtime
        open Android.Views
        open Android.Widget
    
        [<Activity (Label = "setView", MainLauncher = true)>]
        type MainActivity () =
            inherit Activity()
    
            override this.OnCreate (bundle) = base.OnCreate (bundle)
                                              this.SetContentView (Resource_Layout.Hello)