Creating an AppCompatActivity in Elements

Shows how to create an AppCompat (v7) acitvity in Elements.

First create a new Android application, add a reference to android-support-v7-appcompat, and android-support-v4. Make sure both have Copy Local set to true

In your project, change the default acitiity to descend from the compat class (android.support.v7.app.AppCompatActivity):

using java.util;
using android.app;
using android.content;
using android.os;
using android.util;
using android.view;
using android.widget;

namespace org.me.androidapplication8
{
	public class MainActivity: android.support.v7.app.AppCompatActivity
	{
		public override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);

			// Set our view from the "main" layout resource
			ContentView = R.layout.main;
		}
	}
}

Then in AndroidManifest.android-xml under Properties/ add a theme property on the application tag:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
		package="org.me.androidapplication8">
  <application 
        android:label="@string/app_name"
        android:icon="@drawable/icon"
        android:theme="@style/Theme.AppCompat.Light"  <!-- HERE -->
        android:debuggable="true">
    <activity android:label="@string/app_name" android:name="org.me.androidapplication8.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>
  <uses-sdk android:minSdkVersion="4" />
</manifest>

Thats it.

2 posts were split to a new topic: Warnings when creating appcompatactivity