How to use SupportLibrary and Material Theme on android

Hello,

I am just very new on android development and Oxygene. A simple demo is runnging, but how can I use the SupportLibrary with it’s Material Design Theme? I already added the appcompat-v7 package as reference into VS, but in the uses section a cannot use e.g.: android.support.v7.app.AppCompatActivity

You need to add android.support.v7.app to the uses, not android.support.v7.app.AppCompatActivity. Then it should work.

Thanks for the quick response, but there is no such namespace e.g. android.support…
I clicked on add reference and selected: appcompat-v7-23.0.1-sources
But it seems, adding this reference does nothing. Is there something else to do?

That’s the wrong one, you want android-support-v7-appcompat, and android-support-v4, and set both to have CopyLocal true (properties of the reference). I’ll work on hiding the *sources and *docs.

Hm … where do find them?
In the reference list, there is not such a package name. I am using the SDK folder which Android Studio is using: C:\Users\USERNAME\AppData\Local\Android\sdk

It seems that package name is composed of folders:
C:\Users\USERNAME\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\appcompat-v7\23.1.0

They’re supposed to be here:

.\sdk\extras\android\support\v7\appcompat\libs

Make sure they’re installed via the SDK Manager (I think they’re called Android Support Library/Repository)

Thanks. Now I could add that package, but unfortunattely I got some strange errors when using class(AppCompatActivity) instead of class(Activity).

It is refering to some “android.support.v4.app.” packages, but I included v7.

See attachement.

v7 dpends on v4, in .\sdk\extras\android\support\v7\appcompat\libs add a reference to android-support-v4

Thanks. Now it compiles, but then I get an runtime exception:
ClassNotFoundException: org.me.androidapplication3.MainActivity

That exception only appears, when I use class(AppCompatActivity) instead of class(Activity);

Just tried this. This is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
		package="org.me.androidapplication8">
  <!-- the android:debuggable="true" attribute is overwritten by the compiler when the debug info option is set -->
  <application 
        android:label="@string/app_name"
        android:icon="@drawable/icon"
        android:theme="@style/Theme.AppCompat.Light" 
        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>

The activity:

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;
		}
	}
}

CopyLocal for both v4 and v7 is set to true:

Thanks. Now it is working!
I have missed the manifest entry: android:theme="@style/Theme.AppCompat.Light"

Seems older android versions give a very strange class load exceptions, the newer ones give a proper error. Anyway I’m glad it’s solved. Turned this into a snippet for future use Creating an AppCompatActivity in Elements