SlideShare une entreprise Scribd logo
1  sur  59
Télécharger pour lire hors ligne
Xamarin ハンズオ
ン
エクセルソフト株式会社
Business Development Manager
田淵 義人
ytabuchi@xlsoft.com
03-5440-7875 / 080-7015-3586
1
自己紹介 • 田淵義人
• Xamarin コミュニティエバンジェリスト
• Microsoft MVP Visual Studio and Development
Tools 受賞♪
• 目指せ!開発もチョットデキル営業
• マイナビニュースで連載中
• Build Insider Xamarin TIPS で連載中
• 本書きました(Xamarin の章)
• Twitter: @ytabuchi
• facebook: ytabuchi.xlsoft
• Blog: http://ytabuchi.hatenablog.com/
本日の流れ • Xamarin ネイティブ基礎講習 30分
• Xamarin ネイティブハンズオン 1時間半
• 休憩 15分
• Xamarin.Forms 基礎購入 30分
• Xamarin.Forms ハンズオン 1時間半
• キャッチアップ、クロージング
3
モバイルアプリ開発に必要
なモノ
4
今までのアプ
リ開発
5
クロスプラットフォーム
開発環境
“No Silver Bullet”
6
Xamarin(ザマリン)
・ C# / .NET / Visual Studio
・ フル “ネイティブ” アプリ
・ API 100% 移植
・ コード共通化
7
Xamarin のしくみ
2つの開発手法
8
Xamarin ネ
イティブ
9
Xamarin.For
ms
UI “コード”の共
通化
ビルド時にネイ
ティブ UI にマッ
プ
XAML
10
豊富な開発者
用リソース
• 公式ドキュメント
• ペゾルド本(PDFが無料配布中)
日本語の情報
• Japan Xamarin User Group Conference
• Build Insider
• Qiita
• 田淵のブログ
• 各種ブログへのリンク
11
Xamarin ネイティブ
12
C#
13
var employees = new List<Employee>();
var seniors = from e in employees where e.Salary > 50000 select e;
var client = new HttpClient();
var result = await client.GetStringAsync("");
C# 構文
14
EditText input = new EditText(this);
String text = input.getText().toString();
input.addTextChangedListener(new TextWatcher() { ... });
var input = new EditText(this);
string text = input.Text;
input.TextChanged += (sender, e) => { ... };
Xamarin.Android
15
構成
16
ソースファイル
(C#)
UI 定義
(axml)
メタデータ
(Resources)
Activity
17
Activity 1
UI
Code
Activity 2
UI
Code
Activity 3
UI
Code
Data, files,
images など
アプリ
Layout
18
Pi.axml PiActivity.cs
Activity + Layout
19
<LinearLayout ... >
<TextView ... />
<EditText ... />
<Button ... />
<TextView ... />
</LinearLayout>
[Activity]
public class PiActivity : Activity
{
...
...
}
Resource Id
20
[Activity(MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
var et = FindViewById<EditText>(Resource.Id.digitsInput);
...
}
...
}
Intent
21
Intent
22
public class MainActivity : Activity
{
...
void OnClick(object sender, EventArgs e)
{
var intent = new Intent(this, typeof(Activity2));
base.StartActivity(intent);
}
}
Navigation
23
Extra
24
Xamarin.iOS
25
構成
26
ソースファイル
(C#)
UI 定義
(Storyboard + XiB)
メタデータ
(property lists)
Frame
27
Bounds
28
View (コードで)
29
Designer
30
Constraints (制約)
31
Multi Screen
32
Segue
33
Action Segue
34
PerformSegue
35
Xamarin.Forms
36
構成要素・対応システム
37
Pages
Content MasterDetail Navigation Tabbed Carousel
38
Layouts
Stack Absolute Relative Grid ContentView ScrollView Frame
39
Controls
ActivityIndicator BoxView Button DatePicker Editor
Entry Image Label ListView Map
OpenGLView Picker ProgressBar SearchBar Slider
Stepper TableView TimePicker WebView EntryCell
ImageCell SwitchCell TextCell ViewCell
40
レンダリング / マッピング
41
C#
42
Microsoft XAML vs Xamarin.Forms XAML
43
サポートされている XAML 機能
44
45
Attributes
46
x:Name Event
47
Event
48
OnPlatform
49
Data Binding (Mvvm)
50
ListPage.xaml
<ListView ItemsSource="{Binding .}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Image Source="{Binding Photo}" />
<Label Text="{Binding Person}"/>
<Label Text="{Binding Department}" />
<Label Text="{Binding Age, StringFormat='{0}才'}" />
<Label Text="{Binding Followers, StringFormat='Followers: {0}'}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Data Binding (Mvvm)
51
ListPageViewModel.cs
class ListPageViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _person;
public string Person
{
get { return _person; }
set
{
if (_person != value)
{
_person = value;
OnPropertyChanged(nameof(Person));
}
}
}
}
Dependency Service
52
IDialer.cs : PCL
public interface IDialer
{
bool Dial(string number);
}
Use
var dialer = DependencyService.Get<IDialer>();
dialer.Dial(translatedNumber);
Dependency Service
53
PhoneDialer.cs / iOS
[assembly: Dependency(typeof(PhoneDialer))]
public class PhoneDialer : IDialer
{
public bool Dial(string number)
{
return UIApplication.SharedApplication.OpenUrl(
new NSUrl("tel:" + number));
}
}
Custom Renderer
54
RoundedButton.cs (PCL)
public class RoundedButton : Button
{
public RoundedButton() { }
}
Custom Renderer
55
RoundedButton.cs (iOS)
[assembly: ExportRenderer(typeof(RoundedButton), typeof(RoundedButtonRenderer))]
class RoundedButtonRenderer : ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var c = UIColor.FromRGB(0.867f, 1.0f, 0.867f); // #ddffdd
Control.Layer.CornerRadius = 25f;
Control.Layer.BackgroundColor = c.CGColor;
}
}
}
Custom Renderer
56
RoundedButton.cs (Android)
if (Control != null)
{
Control.SetBackgroundResource(Resource.Drawable.RoundedButton);
}
RoundedButton.xml (Android)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#99cc99"/>
<corners android:radius="25dp"/>
</shape>
Xamarin Plugins
https://github.com/xamarin/plugins
57
Xamarin.Forms 完成品
58
ご清聴ありがとうございま
す。ハンズオン楽しんでく
ださい。
ご質問がありましたら、田淵までお気軽にどうぞ
ytabuchi@xlsoft.com
080-7015-3586 / 03-5440-7875
Twitter: @ytabuchi
facebook: ytabuchi.xlsoft
Blog: http://ytabuchi.hatenablog.com/
59

Contenu connexe

Tendances

Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
Hironov OKUYAMA
 

Tendances (20)

Xamarin Overview
Xamarin Overview Xamarin Overview
Xamarin Overview
 
Xamarin 基礎講座 2016年7月版
Xamarin 基礎講座 2016年7月版Xamarin 基礎講座 2016年7月版
Xamarin 基礎講座 2016年7月版
 
#VSUG LT #JXUG の紹介
#VSUG LT #JXUG の紹介#VSUG LT #JXUG の紹介
#VSUG LT #JXUG の紹介
 
Xamarin によるクロスプラットフォームモバイルアプリ開発
Xamarin によるクロスプラットフォームモバイルアプリ開発Xamarin によるクロスプラットフォームモバイルアプリ開発
Xamarin によるクロスプラットフォームモバイルアプリ開発
 
Realm Mobile Platform 概要
Realm Mobile Platform 概要Realm Mobile Platform 概要
Realm Mobile Platform 概要
 
Xamarin の救世主 Unity !
Xamarin の救世主 Unity !Xamarin の救世主 Unity !
Xamarin の救世主 Unity !
 
Xamarin 概要 2017/01/15
Xamarin 概要 2017/01/15Xamarin 概要 2017/01/15
Xamarin 概要 2017/01/15
 
10分でわかる無料になったXamarin
10分でわかる無料になったXamarin10分でわかる無料になったXamarin
10分でわかる無料になったXamarin
 
Xamarin 20141212 モバイルカフェスペシャル 「C#で作るiOS/Androidのクロスプラットフォームスマホアプリ開発」
Xamarin 20141212 モバイルカフェスペシャル 「C#で作るiOS/Androidのクロスプラットフォームスマホアプリ開発」Xamarin 20141212 モバイルカフェスペシャル 「C#で作るiOS/Androidのクロスプラットフォームスマホアプリ開発」
Xamarin 20141212 モバイルカフェスペシャル 「C#で作るiOS/Androidのクロスプラットフォームスマホアプリ開発」
 
Xamarin から使う Azure
Xamarin から使う AzureXamarin から使う Azure
Xamarin から使う Azure
 
Xamarin概要
Xamarin概要Xamarin概要
Xamarin概要
 
Xamarin de:code セッション:Windows Phone / iOS / Android アプリ同時開発のススメ
Xamarin de:code セッション:Windows Phone / iOS / Android アプリ同時開発のススメXamarin de:code セッション:Windows Phone / iOS / Android アプリ同時開発のススメ
Xamarin de:code セッション:Windows Phone / iOS / Android アプリ同時開発のススメ
 
Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
Xamarin によるクロスプラットフォームモバイルアプリ開発(2014.06)
 
Xamarin 概要 @ 「Xamarin」って何? Wエバンジェリストによる特濃「Xamarin」勉強会 Rev2
Xamarin 概要 @ 「Xamarin」って何? Wエバンジェリストによる特濃「Xamarin」勉強会 Rev2Xamarin 概要 @ 「Xamarin」って何? Wエバンジェリストによる特濃「Xamarin」勉強会 Rev2
Xamarin 概要 @ 「Xamarin」って何? Wエバンジェリストによる特濃「Xamarin」勉強会 Rev2
 
Xamarin で今日から始めるクロスプラットフォーム開発
Xamarin で今日から始めるクロスプラットフォーム開発Xamarin で今日から始めるクロスプラットフォーム開発
Xamarin で今日から始めるクロスプラットフォーム開発
 
[MW08] de:code イベントアプリの作り方 ~ Xamarin.Forms で開発しています ~
[MW08] de:code イベントアプリの作り方 ~ Xamarin.Forms で開発しています ~[MW08] de:code イベントアプリの作り方 ~ Xamarin.Forms で開発しています ~
[MW08] de:code イベントアプリの作り方 ~ Xamarin.Forms で開発しています ~
 
NET Standard と Xamarin
NET Standard と XamarinNET Standard と Xamarin
NET Standard と Xamarin
 
Xamarinの歩き方
Xamarinの歩き方Xamarinの歩き方
Xamarinの歩き方
 
20171202 Xamarinの歩き方
20171202 Xamarinの歩き方20171202 Xamarinの歩き方
20171202 Xamarinの歩き方
 
Xamarin 概要 @ 2015/1/29 CROSS 2015
Xamarin 概要 @ 2015/1/29 CROSS 2015Xamarin 概要 @ 2015/1/29 CROSS 2015
Xamarin 概要 @ 2015/1/29 CROSS 2015
 

En vedette

En vedette (17)

Xamarin.Mac をこれからはじめるあなたへ
Xamarin.Mac をこれからはじめるあなたへXamarin.Mac をこれからはじめるあなたへ
Xamarin.Mac をこれからはじめるあなたへ
 
Deep Learning技術の最近の動向とPreferred Networksの取り組み
Deep Learning技術の最近の動向とPreferred Networksの取り組みDeep Learning技術の最近の動向とPreferred Networksの取り組み
Deep Learning技術の最近の動向とPreferred Networksの取り組み
 
Xamarin.forms入門
Xamarin.forms入門Xamarin.forms入門
Xamarin.forms入門
 
iOS の動画アプリ開発に Xamarin を使ってみた @JXUG #2 East
iOS の動画アプリ開発に Xamarin を使ってみた @JXUG #2 EastiOS の動画アプリ開発に Xamarin を使ってみた @JXUG #2 East
iOS の動画アプリ開発に Xamarin を使ってみた @JXUG #2 East
 
Xamarin.forms実践投入してみて
Xamarin.forms実践投入してみてXamarin.forms実践投入してみて
Xamarin.forms実践投入してみて
 
Raheja Vanya Sector 99A gurgaon
Raheja Vanya Sector 99A gurgaon Raheja Vanya Sector 99A gurgaon
Raheja Vanya Sector 99A gurgaon
 
Researching the idea of flexible and open learning spaces, student’s agency a...
Researching the idea of flexible and open learning spaces, student’s agency a...Researching the idea of flexible and open learning spaces, student’s agency a...
Researching the idea of flexible and open learning spaces, student’s agency a...
 
#SciChallenge2017 Smoking
#SciChallenge2017 Smoking#SciChallenge2017 Smoking
#SciChallenge2017 Smoking
 
Journal of Endocrine Disorders
Journal of Endocrine DisordersJournal of Endocrine Disorders
Journal of Endocrine Disorders
 
CaribeWave 2017 Agenda de Cooperación #SemCaribe
CaribeWave 2017 Agenda de Cooperación #SemCaribeCaribeWave 2017 Agenda de Cooperación #SemCaribe
CaribeWave 2017 Agenda de Cooperación #SemCaribe
 
El nuevo reglamento de protección de datos en la economía digital
El nuevo reglamento de protección de datos en la economía digitalEl nuevo reglamento de protección de datos en la economía digital
El nuevo reglamento de protección de datos en la economía digital
 
World Tuberculosis Day 2017 - Tuberculosis situation in the EU/EEA, 2015
World Tuberculosis Day 2017 - Tuberculosis situation in the EU/EEA, 2015 World Tuberculosis Day 2017 - Tuberculosis situation in the EU/EEA, 2015
World Tuberculosis Day 2017 - Tuberculosis situation in the EU/EEA, 2015
 
XAML入門
XAML入門XAML入門
XAML入門
 
XDi Presentation_Lean UX-Workshop@MCBW2017
XDi Presentation_Lean UX-Workshop@MCBW2017XDi Presentation_Lean UX-Workshop@MCBW2017
XDi Presentation_Lean UX-Workshop@MCBW2017
 
Production ready big ml workflows from zero to hero daniel marcous @ waze
Production ready big ml workflows from zero to hero daniel marcous @ wazeProduction ready big ml workflows from zero to hero daniel marcous @ waze
Production ready big ml workflows from zero to hero daniel marcous @ waze
 
Improve collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contractsImprove collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contracts
 
動画配信の基礎知識
動画配信の基礎知識動画配信の基礎知識
動画配信の基礎知識
 

Similaire à Xamarin 基礎講座

スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
Shinichi Tomita
 

Similaire à Xamarin 基礎講座 (20)

Xamarin を使うとどんなことができるの?
Xamarin を使うとどんなことができるの?Xamarin を使うとどんなことができるの?
Xamarin を使うとどんなことができるの?
 
Xamarin基礎講座 Xamarinハンズオン(2016.09 浜松) #JXUG #jaghama
Xamarin基礎講座 Xamarinハンズオン(2016.09 浜松) #JXUG #jaghamaXamarin基礎講座 Xamarinハンズオン(2016.09 浜松) #JXUG #jaghama
Xamarin基礎講座 Xamarinハンズオン(2016.09 浜松) #JXUG #jaghama
 
C# と Xamarin
C# と XamarinC# と Xamarin
C# と Xamarin
 
Xamarin.Forms のこれまでとこれから
Xamarin.Forms のこれまでとこれからXamarin.Forms のこれまでとこれから
Xamarin.Forms のこれまでとこれから
 
Xamarin 概要 2014年08月版
Xamarin 概要 2014年08月版Xamarin 概要 2014年08月版
Xamarin 概要 2014年08月版
 
Xamarin.Forms.WPF を試してみた
Xamarin.Forms.WPF を試してみたXamarin.Forms.WPF を試してみた
Xamarin.Forms.WPF を試してみた
 
ゆるふわ Xamarin Tips
ゆるふわ Xamarin Tipsゆるふわ Xamarin Tips
ゆるふわ Xamarin Tips
 
Xamarin 対応開発ツールで効率良くクロスプラットフォーム開発
Xamarin 対応開発ツールで効率良くクロスプラットフォーム開発Xamarin 対応開発ツールで効率良くクロスプラットフォーム開発
Xamarin 対応開発ツールで効率良くクロスプラットフォーム開発
 
Computer Vision と Translator Text API 使ってみた
Computer Vision と Translator Text API 使ってみたComputer Vision と Translator Text API 使ってみた
Computer Vision と Translator Text API 使ってみた
 
Xamarin の概要と活用事例
Xamarin の概要と活用事例Xamarin の概要と活用事例
Xamarin の概要と活用事例
 
Xamarin 概要 @ 2014/10/18 わんくま同盟 東京勉強会 #92
Xamarin 概要 @ 2014/10/18 わんくま同盟 東京勉強会 #92Xamarin 概要 @ 2014/10/18 わんくま同盟 東京勉強会 #92
Xamarin 概要 @ 2014/10/18 わんくま同盟 東京勉強会 #92
 
Microsoftの開発環境
Microsoftの開発環境Microsoftの開発環境
Microsoftの開発環境
 
NET MAUI for .NET 7 for iOS, Android app development
 NET MAUI for .NET 7 for iOS, Android app development  NET MAUI for .NET 7 for iOS, Android app development
NET MAUI for .NET 7 for iOS, Android app development
 
Xamarin 概要 @ 2014/11/08 第2回 Japan Xamarin User Group Conference 西日本編
Xamarin 概要 @ 2014/11/08 第2回 Japan Xamarin User Group Conference 西日本編Xamarin 概要 @ 2014/11/08 第2回 Japan Xamarin User Group Conference 西日本編
Xamarin 概要 @ 2014/11/08 第2回 Japan Xamarin User Group Conference 西日本編
 
Net advantage 2012 volume2 最新情報 xaml プラットフォーム編
Net advantage 2012 volume2 最新情報 xaml プラットフォーム編Net advantage 2012 volume2 最新情報 xaml プラットフォーム編
Net advantage 2012 volume2 最新情報 xaml プラットフォーム編
 
よく聞くけど、「SharePoint リストの 5,000 件問題」ってなんなの?
よく聞くけど、「SharePoint リストの 5,000 件問題」ってなんなの?よく聞くけど、「SharePoint リストの 5,000 件問題」ってなんなの?
よく聞くけど、「SharePoint リストの 5,000 件問題」ってなんなの?
 
XamarinStudio勉強会 2014/09/08
XamarinStudio勉強会 2014/09/08XamarinStudio勉強会 2014/09/08
XamarinStudio勉強会 2014/09/08
 
Xamarin 概要~Windows Embedded の業務用端末から Android へのシームレスな移行~
Xamarin 概要~Windows Embedded の業務用端末から Android へのシームレスな移行~Xamarin 概要~Windows Embedded の業務用端末から Android へのシームレスな移行~
Xamarin 概要~Windows Embedded の業務用端末から Android へのシームレスな移行~
 
TeamsのチャネルとやりとりするWeb Applicationを作ったお話
TeamsのチャネルとやりとりするWeb Applicationを作ったお話TeamsのチャネルとやりとりするWeb Applicationを作ったお話
TeamsのチャネルとやりとりするWeb Applicationを作ったお話
 
スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
スマートデバイス×HTML5で
 企業情報システムはどう変わる? ~最新動向から考えるエンタープライズWebの現在と未来~
 

Plus de Yoshito Tabuchi

Plus de Yoshito Tabuchi (15)

Kong Summit 2021 振り返り
Kong Summit 2021 振り返りKong Summit 2021 振り返り
Kong Summit 2021 振り返り
 
Kong 概要
Kong 概要Kong 概要
Kong 概要
 
勉強会参加のススメ
勉強会参加のススメ勉強会参加のススメ
勉強会参加のススメ
 
Kong Enterprise の紹介
Kong Enterprise の紹介Kong Enterprise の紹介
Kong Enterprise の紹介
 
How does a sales person grow up his community
How does a sales person grow up his communityHow does a sales person grow up his community
How does a sales person grow up his community
 
Xamarin で Cognitive Services を使う
Xamarin で Cognitive Services を使うXamarin で Cognitive Services を使う
Xamarin で Cognitive Services を使う
 
Xamarin で Cognitive Services を使ってみよう
Xamarin で Cognitive Services を使ってみようXamarin で Cognitive Services を使ってみよう
Xamarin で Cognitive Services を使ってみよう
 
Xamarinを触り始めた頃の話〜触りたい人に向けて〜
Xamarinを触り始めた頃の話〜触りたい人に向けて〜Xamarinを触り始めた頃の話〜触りたい人に向けて〜
Xamarinを触り始めた頃の話〜触りたい人に向けて〜
 
2018年のXamarinの概要と活用方法
2018年のXamarinの概要と活用方法2018年のXamarinの概要と活用方法
2018年のXamarinの概要と活用方法
 
モバイル向けクロスプラットフォーム開発ツール Xamarin の概要とその利点
モバイル向けクロスプラットフォーム開発ツール Xamarin の概要とその利点モバイル向けクロスプラットフォーム開発ツール Xamarin の概要とその利点
モバイル向けクロスプラットフォーム開発ツール Xamarin の概要とその利点
 
Xamarin概要+最新情報
Xamarin概要+最新情報Xamarin概要+最新情報
Xamarin概要+最新情報
 
ちょっとエモい話
ちょっとエモい話ちょっとエモい話
ちょっとエモい話
 
Xamarinをこれから始める皆様へ
Xamarinをこれから始める皆様へXamarinをこれから始める皆様へ
Xamarinをこれから始める皆様へ
 
Xamarin 概要
Xamarin 概要Xamarin 概要
Xamarin 概要
 
Xamarin バッドノウハウ大全
Xamarin バッドノウハウ大全Xamarin バッドノウハウ大全
Xamarin バッドノウハウ大全
 

Xamarin 基礎講座