Skip to content

Commit e655169

Browse files
Merge pull request #5 from SyncfusionExamples/ComboSample
Added sample for ComboBoxWordWrap
2 parents 137296c + d7470f6 commit e655169

29 files changed

+34002
-0
lines changed

ComboBoxWordWrap/ComboWordWrap.sln

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34309.116
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComboWordWrap.Android", "ComboWordWrap\ComboWordWrap.Android\ComboWordWrap.Android.csproj", "{E9BA50AC-3779-45EA-A3DB-588FC721C267}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComboWordWrap", "ComboWordWrap\ComboWordWrap\ComboWordWrap.csproj", "{008C7B0F-1C9B-42F7-B397-C57245A29BBC}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|ARM = Debug|ARM
14+
Debug|iPhone = Debug|iPhone
15+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
16+
Debug|x64 = Debug|x64
17+
Debug|x86 = Debug|x86
18+
Release|Any CPU = Release|Any CPU
19+
Release|ARM = Release|ARM
20+
Release|iPhone = Release|iPhone
21+
Release|iPhoneSimulator = Release|iPhoneSimulator
22+
Release|x64 = Release|x64
23+
Release|x86 = Release|x86
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
29+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|ARM.ActiveCfg = Debug|Any CPU
30+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|ARM.Build.0 = Debug|Any CPU
31+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|ARM.Deploy.0 = Debug|Any CPU
32+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhone.ActiveCfg = Debug|Any CPU
33+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhone.Build.0 = Debug|Any CPU
34+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhone.Deploy.0 = Debug|Any CPU
35+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
36+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
37+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
38+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x64.ActiveCfg = Debug|Any CPU
39+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x64.Build.0 = Debug|Any CPU
40+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x64.Deploy.0 = Debug|Any CPU
41+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x86.Build.0 = Debug|Any CPU
43+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Debug|x86.Deploy.0 = Debug|Any CPU
44+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|Any CPU.Deploy.0 = Release|Any CPU
47+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|ARM.ActiveCfg = Release|Any CPU
48+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|ARM.Build.0 = Release|Any CPU
49+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|ARM.Deploy.0 = Release|Any CPU
50+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhone.ActiveCfg = Release|Any CPU
51+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhone.Build.0 = Release|Any CPU
52+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhone.Deploy.0 = Release|Any CPU
53+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
54+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
55+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
56+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x64.ActiveCfg = Release|Any CPU
57+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x64.Build.0 = Release|Any CPU
58+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x64.Deploy.0 = Release|Any CPU
59+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x86.ActiveCfg = Release|Any CPU
60+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x86.Build.0 = Release|Any CPU
61+
{E9BA50AC-3779-45EA-A3DB-588FC721C267}.Release|x86.Deploy.0 = Release|Any CPU
62+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
65+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|ARM.ActiveCfg = Debug|Any CPU
66+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|ARM.Build.0 = Debug|Any CPU
67+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|ARM.Deploy.0 = Debug|Any CPU
68+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhone.ActiveCfg = Debug|Any CPU
69+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhone.Build.0 = Debug|Any CPU
70+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhone.Deploy.0 = Debug|Any CPU
71+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
72+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
73+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
74+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x64.ActiveCfg = Debug|Any CPU
75+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x64.Build.0 = Debug|Any CPU
76+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x64.Deploy.0 = Debug|Any CPU
77+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x86.ActiveCfg = Debug|Any CPU
78+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x86.Build.0 = Debug|Any CPU
79+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Debug|x86.Deploy.0 = Debug|Any CPU
80+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|Any CPU.Deploy.0 = Release|Any CPU
83+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|ARM.ActiveCfg = Release|Any CPU
84+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|ARM.Build.0 = Release|Any CPU
85+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|ARM.Deploy.0 = Release|Any CPU
86+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhone.ActiveCfg = Release|Any CPU
87+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhone.Build.0 = Release|Any CPU
88+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhone.Deploy.0 = Release|Any CPU
89+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
90+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
91+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
92+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x64.ActiveCfg = Release|Any CPU
93+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x64.Build.0 = Release|Any CPU
94+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x64.Deploy.0 = Release|Any CPU
95+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x86.ActiveCfg = Release|Any CPU
96+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x86.Build.0 = Release|Any CPU
97+
{008C7B0F-1C9B-42F7-B397-C57245A29BBC}.Release|x86.Deploy.0 = Release|Any CPU
98+
EndGlobalSection
99+
GlobalSection(SolutionProperties) = preSolution
100+
HideSolutionNode = FALSE
101+
EndGlobalSection
102+
GlobalSection(ExtensibilityGlobals) = postSolution
103+
SolutionGuid = {A62D36B5-F92D-45F4-A226-BF16B4F8CF8B}
104+
EndGlobalSection
105+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with your package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{E9BA50AC-3779-45EA-A3DB-588FC721C267}</ProjectGuid>
7+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
8+
<TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
9+
<OutputType>Library</OutputType>
10+
<RootNamespace>ComboWordWrap.Droid</RootNamespace>
11+
<AssemblyName>ComboWordWrap.Android</AssemblyName>
12+
<Deterministic>True</Deterministic>
13+
<AndroidApplication>True</AndroidApplication>
14+
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
15+
<AndroidResgenClass>Resource</AndroidResgenClass>
16+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
17+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
18+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
19+
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
20+
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
21+
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
22+
<AndroidUseAapt2>true</AndroidUseAapt2>
23+
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
28+
<DebugSymbols>true</DebugSymbols>
29+
<DebugType>portable</DebugType>
30+
<Optimize>false</Optimize>
31+
<OutputPath>bin\Debug</OutputPath>
32+
<DefineConstants>DEBUG;</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<AndroidLinkMode>None</AndroidLinkMode>
36+
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
39+
<DebugSymbols>true</DebugSymbols>
40+
<DebugType>portable</DebugType>
41+
<Optimize>true</Optimize>
42+
<OutputPath>bin\Release</OutputPath>
43+
<ErrorReport>prompt</ErrorReport>
44+
<WarningLevel>4</WarningLevel>
45+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
46+
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
47+
</PropertyGroup>
48+
<ItemGroup>
49+
<Reference Include="Mono.Android" />
50+
<Reference Include="System" />
51+
<Reference Include="System.Core" />
52+
<Reference Include="System.Xml.Linq" />
53+
<Reference Include="System.Xml" />
54+
<Reference Include="System.Numerics" />
55+
<Reference Include="System.Numerics.Vectors" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<PackageReference Include="Syncfusion.Xamarin.SfComboBox" Version="*"/>
59+
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
60+
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<Compile Include="CustomRenderer.cs" />
64+
<Compile Include="MainActivity.cs" />
65+
<Compile Include="Resources\Resource.designer.cs" />
66+
<Compile Include="Properties\AssemblyInfo.cs" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<None Include="Resources\AboutResources.txt" />
70+
<None Include="Assets\AboutAssets.txt" />
71+
<None Include="Properties\AndroidManifest.xml" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<AndroidResource Include="Resources\values\styles.xml" />
75+
<AndroidResource Include="Resources\values\colors.xml" />
76+
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon.xml" />
77+
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon_round.xml" />
78+
<AndroidResource Include="Resources\mipmap-hdpi\icon.png" />
79+
<AndroidResource Include="Resources\mipmap-hdpi\launcher_foreground.png" />
80+
<AndroidResource Include="Resources\mipmap-mdpi\icon.png" />
81+
<AndroidResource Include="Resources\mipmap-mdpi\launcher_foreground.png" />
82+
<AndroidResource Include="Resources\mipmap-xhdpi\icon.png" />
83+
<AndroidResource Include="Resources\mipmap-xhdpi\launcher_foreground.png" />
84+
<AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" />
85+
<AndroidResource Include="Resources\mipmap-xxhdpi\launcher_foreground.png" />
86+
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
87+
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
88+
</ItemGroup>
89+
<ItemGroup>
90+
<Folder Include="Resources\drawable\" />
91+
</ItemGroup>
92+
<ItemGroup>
93+
<ProjectReference Include="..\ComboWordWrap\ComboWordWrap.csproj">
94+
<Project>{DC2B8472-0B3D-4CF0-930A-47DC72220F7D}</Project>
95+
<Name>ComboWordWrap</Name>
96+
</ProjectReference>
97+
</ItemGroup>
98+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
99+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Android.App;
2+
using Android.Content;
3+
using Android.OS;
4+
using Android.Runtime;
5+
using Android.Views;
6+
using Android.Widget;
7+
using ComboWordWrap;
8+
using ComboWordWrap.Droid;
9+
using Syncfusion.Android.ComboBox;
10+
using Syncfusion.XForms.Android.ComboBox;
11+
using System;
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
using System.Text;
15+
using Xamarin.Forms;
16+
using Xamarin.Forms.Platform.Android;
17+
[assembly: ExportRenderer(typeof(SfCustomComboBox), typeof(CustomRenderer))]
18+
namespace ComboWordWrap.Droid
19+
{
20+
public class CustomRenderer:SfComboBoxRenderer
21+
{
22+
public CustomRenderer(Context context) : base(context)
23+
{
24+
}
25+
26+
protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.XForms.ComboBox.SfComboBox> e)
27+
{
28+
base.OnElementChanged(e);
29+
Control.GetAutoEditText().SetLines(8);
30+
Control.GetAutoEditText().SetHorizontallyScrolling(false);
31+
}
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
using Android.App;
4+
using Android.Content.PM;
5+
using Android.Runtime;
6+
using Android.OS;
7+
8+
namespace ComboWordWrap.Droid
9+
{
10+
[Activity(Label = "ComboWordWrap", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
11+
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
12+
{
13+
protected override void OnCreate(Bundle savedInstanceState)
14+
{
15+
base.OnCreate(savedInstanceState);
16+
17+
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
18+
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
19+
LoadApplication(new App());
20+
}
21+
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
22+
{
23+
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
24+
25+
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
26+
}
27+
}
28+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.combowordwrap">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
4+
<application android:label="ComboWordWrap.Android" android:theme="@style/MainTheme"></application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
</manifest>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Android.App;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("ComboWordWrap.Android")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("ComboWordWrap.Android")]
14+
[assembly: AssemblyCopyright("Copyright © 2014")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
[assembly: ComVisible(false)]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
[assembly: AssemblyVersion("1.0.0.0")]
26+
[assembly: AssemblyFileVersion("1.0.0.0")]
27+
28+
// Add some common permissions, these can be removed if not needed
29+
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
30+
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.xml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable-hdpi/
12+
icon.png
13+
14+
drawable-ldpi/
15+
icon.png
16+
17+
drawable-mdpi/
18+
icon.png
19+
20+
layout/
21+
main.xml
22+
23+
values/
24+
strings.xml
25+
26+
In order to get the build system to recognize Android resources, set the build action to
27+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
28+
instead operate on resource IDs. When you compile an Android application that uses resources,
29+
the build system will package the resources for distribution and generate a class called
30+
"Resource" that contains the tokens for each one of the resources included. For example,
31+
for the above Resources layout, this is what the Resource class would expose:
32+
33+
public class Resource {
34+
public class drawable {
35+
public const int icon = 0x123;
36+
}
37+
38+
public class layout {
39+
public const int main = 0x456;
40+
}
41+
42+
public class strings {
43+
public const int first_string = 0xabc;
44+
public const int second_string = 0xbcd;
45+
}
46+
}
47+
48+
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49+
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50+
string in the dictionary file values/strings.xml.

0 commit comments

Comments
 (0)