0

Is there a way to change the startup code in Xamarin Studio?

It's starting to bother me the startup code, I don't need most of the code

Xamarin Studio 6.0.2

Change from this:

namespace App2
{
    [Activity(MainLauncher = true, Icon = "@mipmap/icon")]
    public class MainActivity : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.myButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
        }
    }
}

to this:

namespace App1
{
    [Activity(MainLauncher = true, Icon = "@mipmap/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);
        }
    }
}

I checked the Code Templates inside Options, but those are snippets

If so, how?

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
NAYIR55
  • 105
  • 5
  • 17

2 Answers2

0

After some digging in my Xamarin Studio install folder I found what I was looking for...

If someone is interested, here are the startup code templates route

MainActivity.cs

Main.axml

C:\Program Files (x86)\Xamarin Studio\AddIns\MonoDevelop.MonoDroid\templates\Project\AndroidApp

Just don't forget to make a copy of the original files

NAYIR55
  • 105
  • 5
  • 17
  • It is an irrelevant answer you are posting, he is asking how to change the code for startup the application. – Ashish-BeJovial Sep 08 '16 at 08:33
  • This is my own answer, I found the code template inside that folder after Xamarin Studio and Xamarin for adroid are installed, I was asking how to change the template to be more neutral and get rid of the innecesary code – NAYIR55 Sep 08 '16 at 08:38
0

You should try following url, as per your question you are reloading the state when application come from the background, so in this case you have to override methods and have to write the code. For this please follow following link.

https://developer.xamarin.com/guides/android/application_fundamentals/activity_lifecycle/

Ashish-BeJovial
  • 1,829
  • 3
  • 38
  • 62