Book Image

Learning Xamarin studio

By : William Smith
Book Image

Learning Xamarin studio

By: William Smith

Overview of this book

Table of Contents (16 chapters)
Learning Xamarin Studio
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Testing in an Android emulator


For this exercise, you're creating a new Android solution and performing several basic functions using an Android emulator. Again, your app will focus on handling hardware state changes and user interactions with your Activity:

  1. Create a new solution.

  2. From the Android group, select the Android Ice Cream Sandwich Application template.

  3. Name your project AndroidInMotion and click the OK button.

  4. Your solution should have opened to the MainActivity.cs file. If not, open that file now.

  5. Delete this line of code from the MainActivity.cs file:

    Int count = 1;
  6. Replace all of the code in the OnCreate() method with the following code:

    base.OnCreate (bundle);
    
    var relLayout = new RelativeLayout (this);
    
    var layoutParams = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
    relLayout.LayoutParameters = layoutParams;
    
    var orientation = WindowManager.DefaultDisplay.Rotation;
    RelativeLayout.LayoutParams textViewLayoutParams;
    
    if (orientation...