forked from xamarin/XobotOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.samples
96 lines (67 loc) · 3 KB
/
README.samples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Quick tutorial on how to create a new sample application in MonoDevelop.
Setting up the Project:
* Create a new library project and add a reference to XobotOS-debug
(don't worry, XobotOS-debug is an executable project)
* Create your AndroidManifest.xml and res/ directory.
For instance:
===[AndroidManifest.xml]===
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XobotOS.ScrollView">
<application android:name="TestApplication"
android:label="XobotOS Scroll View">
<activity android:name="TestActivity">
</activity>
</application>
</manifest>
====
====[res/layout/scroll_view.xml]====
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/venus"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>
====
* Create your Application and Activity classes as specified in the manifest.
* To build the resources, you need to run xorpt.pl prior to building:
Go to Project / Options / Build / Custom Command, then add a new
"Before Build" command.
Command: ${SolutionDir}/xorpt.pl ${ProjectDir} ${ProjectConfigName}
Working Directory: ${ProjectDir}
Don't check Run on external console.
This will add the following to the .csproj:
<CustomCommands>
<CustomCommands>
<Command type="BeforeBuild" command="${SolutionDir}/xorpt.pl ${ProjectDir} ${ProjectConfigName}" workingdir="${ProjectDir}" />
</CustomCommands>
</CustomCommands>
* Build the project.
This will run xorpt and generate the ProjectName-res.zip in the project
directory.
Xorpt (XobotOS Resource Packaging Tool) is a slightly modified version of
Android's aapt tool, which creates a R.cs and packages the
AndroidManifest.xml and all resources into a resources .zip file.
We embed this resource file in the assembly.
* Add the generated R.cs to the build.
* Add the generated ProjectName-res.zip as an embedded resource called
"XobotOS.Resources" (you must use this name).
To do this, add the file, then
right-click / Build Action / EmbeddedResource
right-click / Properties and set Resource ID to "XobotOS.Resources".
* Now you can simply access your resources, for instance:
public class TestActivity : Activity
{
protected override void onCreate (android.os.Bundle savedInstanceState)
{
base.onCreate (savedInstanceState);
setContentView (R.layout.scroll_view);
}
}
* Rebuild the project to make sure the resource file is embedded.
To run this, simply run XobotOS.exe and pass it the assembly filename as
command-line argument.