forked from dotnet/android-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
784 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Any raw assets you want to be deployed with your application can be placed in | ||
this directory (and child directories) and given a Build Action of "AndroidAsset". | ||
|
||
These files will be deployed with your package and will be accessible using Android's | ||
AssetManager, like this: | ||
|
||
public class ReadAsset : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
InputStream input = Assets.Open ("my_asset.txt"); | ||
} | ||
} | ||
|
||
Additionally, some Android functions will automatically load asset files: | ||
|
||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.0</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}</ProjectGuid> | ||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>DoneBar</RootNamespace> | ||
<AndroidApplication>True</AndroidApplication> | ||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> | ||
<AndroidResgenClass>Resource</AndroidResgenClass> | ||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> | ||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> | ||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> | ||
<AssemblyName>DoneBar</AssemblyName> | ||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> | ||
<TargetFrameworkVersion>v4.3</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AndroidLinkMode>None</AndroidLinkMode> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>full</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Mono.Android" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Resources\Resource.designer.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SampleDashboardActivity.cs" /> | ||
<Compile Include="DoneBarActivity.cs" /> | ||
<Compile Include="DoneButtonActivity.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Resources\AboutResources.txt" /> | ||
<None Include="Assets\AboutAssets.txt" /> | ||
<None Include="Properties\AndroidManifest.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\values\Strings.xml" /> | ||
<AndroidResource Include="Resources\layout\activity_sample_dashboard.axml" /> | ||
<AndroidResource Include="Resources\values\styles.xml" /> | ||
<AndroidResource Include="Resources\values\dimens.xml" /> | ||
<AndroidResource Include="Resources\drawable-hdpi\icon.png" /> | ||
<AndroidResource Include="Resources\drawable-mdpi\icon.png" /> | ||
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" /> | ||
<AndroidResource Include="Resources\drawable-xxhdpi\icon.png" /> | ||
<AndroidResource Include="Resources\drawable-hdpi\ic_action_cancel.png" /> | ||
<AndroidResource Include="Resources\drawable-hdpi\ic_action_done.png" /> | ||
<AndroidResource Include="Resources\drawable-mdpi\ic_action_cancel.png" /> | ||
<AndroidResource Include="Resources\drawable-mdpi\ic_action_done.png" /> | ||
<AndroidResource Include="Resources\drawable-xhdpi\ic_action_cancel.png" /> | ||
<AndroidResource Include="Resources\drawable-xhdpi\ic_action_done.png" /> | ||
<AndroidResource Include="Resources\drawable-xhdpi\sample_dashboard_item_background.9.png" /> | ||
<AndroidResource Include="Resources\layout\sample_dashboard_item.axml" /> | ||
<AndroidResource Include="Resources\layout\actionbar_custom_view_done_cancel.axml" /> | ||
<AndroidResource Include="Resources\layout\include_cancel_button.axml" /> | ||
<AndroidResource Include="Resources\layout\include_done_button.axml" /> | ||
<AndroidResource Include="Resources\layout\activity_done_bar.axml" /> | ||
<AndroidResource Include="Resources\layout\actionbar_custom_view_done.axml" /> | ||
<AndroidResource Include="Resources\layout\activity_done_button.axml" /> | ||
<AndroidResource Include="Resources\menu\cancel.axml" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> | ||
<ItemGroup> | ||
<Folder Include="Resources\drawable-hdpi\" /> | ||
<Folder Include="Resources\drawable-xhdpi\" /> | ||
<Folder Include="Resources\drawable-xxhdpi\" /> | ||
<Folder Include="Resources\menu\" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DoneBar", "DoneBar.csproj", "{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A1A317BA-E5DD-41E3-80F3-1F33B546BAB9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(MonoDevelopProperties) = preSolution | ||
StartupItem = DoneBar.csproj | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2013 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
|
||
/** | ||
* A sample activity demonstrating the "done bar" alternative action bar presentation. For a more | ||
* detailed description see {@link R.string.done_bar_description}. | ||
*/ | ||
|
||
namespace DoneBar | ||
{ | ||
[Activity (Label = "DoneBarActivity", Theme="@style/Theme.Sample")] | ||
public class DoneBarActivity : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
// Inflate a "Done/Cancel" custom action bar view. | ||
var inflater = (LayoutInflater) ActionBar.ThemedContext.GetSystemService (Context.LayoutInflaterService); | ||
View customActionBarView = inflater.Inflate (Resource.Layout.actionbar_custom_view_done_cancel, null); | ||
|
||
customActionBarView.FindViewById (Resource.Id.actionbar_done).Click += delegate { | ||
// "Done" | ||
Finish(); | ||
}; | ||
|
||
customActionBarView.FindViewById (Resource.Id.actionbar_cancel).Click += delegate { | ||
// "Cancel" | ||
Finish(); | ||
}; | ||
|
||
// Show the custom action bar view and hide the normal Home icon and title. | ||
ActionBar.SetDisplayOptions (ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom | | ||
ActionBarDisplayOptions.ShowHome | ActionBarDisplayOptions.ShowTitle); | ||
|
||
ActionBar.SetCustomView (customActionBarView, new ActionBar.LayoutParams ( | ||
ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); | ||
|
||
SetContentView (Resource.Layout.activity_done_bar); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
|
||
/** | ||
* A sample activity demonstrating the "done button" alternative action bar presentation. For a more | ||
* detailed description see {@link R.string.done_button_description}. | ||
*/ | ||
|
||
namespace DoneBar | ||
{ | ||
[Activity (Label = "DoneButtonActivity", Theme="@style/Theme.Sample")] | ||
public class DoneButtonActivity : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
// Inflate a "Done" custom action bar view to serve as the "Up" affordance. | ||
var inflater = (LayoutInflater) ActionBar.ThemedContext.GetSystemService (Context.LayoutInflaterService); | ||
View customActionBarView = inflater.Inflate (Resource.Layout.actionbar_custom_view_done, null); | ||
|
||
customActionBarView.FindViewById (Resource.Id.actionbar_done).Click += delegate { | ||
// "Done" | ||
Finish(); | ||
}; | ||
|
||
// Show the custom action bar view and hide the normal Home icon and title. | ||
|
||
ActionBar.SetDisplayOptions (ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom | ||
| ActionBarDisplayOptions.ShowHome | ActionBarDisplayOptions.ShowTitle); | ||
|
||
ActionBar.CustomView = customActionBarView; | ||
|
||
SetContentView (Resource.Layout.activity_done_button); | ||
} | ||
|
||
public override bool OnCreateOptionsMenu (IMenu menu) | ||
{ | ||
base.OnCreateOptionsMenu (menu); | ||
MenuInflater.Inflate (Resource.Menu.cancel, menu); | ||
return true; | ||
} | ||
|
||
public override bool OnOptionsItemSelected (IMenuItem item) | ||
{ | ||
switch (item.ItemId) { | ||
case Resource.Id.cancel: | ||
// "Cancel" | ||
Finish (); | ||
return true; | ||
} | ||
return base.OnOptionsItemSelected (item); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.donebar"> | ||
<uses-sdk android:minSdkVersion="16" /> | ||
<application android:label="DoneBar" android:icon="@drawable/icon"> | ||
</application> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using Android.App; | ||
|
||
// Information about this assembly is defined by the following attributes. | ||
// Change them to the values specific to your project. | ||
[assembly: AssemblyTitle ("DoneBar")] | ||
[assembly: AssemblyDescription ("")] | ||
[assembly: AssemblyConfiguration ("")] | ||
[assembly: AssemblyCompany ("")] | ||
[assembly: AssemblyProduct ("")] | ||
[assembly: AssemblyCopyright ("petercollins")] | ||
[assembly: AssemblyTrademark ("")] | ||
[assembly: AssemblyCulture ("")] | ||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". | ||
// The form "{Major}.{Minor}.*" will automatically update the build and revision, | ||
// and "{Major}.{Minor}.{Build}.*" will update just the revision. | ||
[assembly: AssemblyVersion ("1.0.0")] | ||
// The following attributes are used to specify the signing key for the assembly, | ||
// if desired. See the Mono documentation for more information about signing. | ||
//[assembly: AssemblyDelaySign(false)] | ||
//[assembly: AssemblyKeyFile("")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Done Bar | ||
================== | ||
This sample demonstrates how to create two different custom ActionBars. | ||
|
||
Based on Google's Android-18 sample "DoneBar". | ||
Ported by: Peter Collins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (main.axml), | ||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
drawable/ | ||
icon.png | ||
|
||
layout/ | ||
main.axml | ||
|
||
values/ | ||
strings.xml | ||
|
||
In order to get the build system to recognize Android resources, set the build action to | ||
"AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called "R" | ||
(this is an Android convention) that contains the tokens for each one of the resources | ||
included. For example, for the above Resources layout, this is what the R class would expose: | ||
|
||
public class R { | ||
public class drawable { | ||
public const int icon = 0x123; | ||
} | ||
|
||
public class layout { | ||
public const int main = 0x456; | ||
} | ||
|
||
public class strings { | ||
public const int first_string = 0xabc; | ||
public const int second_string = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main | ||
to reference the layout/main.axml file, or R.strings.first_string to reference the first | ||
string in the dictionary file values/strings.xml. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+196 Bytes
DoneBar/Resources/drawable-xhdpi/sample_dashboard_item_background.9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="horizontal" | ||
android:divider="?android:attr/dividerVertical" | ||
android:showDividers="end" | ||
android:dividerPadding="12dp"> | ||
<include | ||
layout="@layout/include_done_button" /> | ||
</LinearLayout> |
13 changes: 13 additions & 0 deletions
13
DoneBar/Resources/layout/actionbar_custom_view_done_cancel.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="horizontal" | ||
android:divider="?android:attr/dividerVertical" | ||
android:showDividers="middle" | ||
android:dividerPadding="12dp"> | ||
<include | ||
layout="@layout/include_cancel_button" /> | ||
<include | ||
layout="@layout/include_done_button" /> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<LinearLayout | ||
style="@style/Widget.SampleContentContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
<TextView | ||
style="@style/Widget.SampleMessage" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/done_bar_description" /> | ||
</LinearLayout> | ||
</ScrollView> |
Oops, something went wrong.