2. Xamarin 설치 하드웨어
• UWP(Universal Window Platform)을 개발
하려면 Windows10이 필수
• Windows Store/Windows Phone 8.1을 개
발하려면 Window8.1이 필수
• Android만 개발하려면 Windows7도 가능
– Android 실제기기를 준비하면 더 좋음
3. 당신의 HDD/SDD는 충분한가?
• C#/.NET (Xamarin) 10GB
• Android 용 Microsoft Visual Studio 에뮬
레이터(2016年1月) 1GB
– 공통툴 혹은 개발 키트
• Android 네이티브 개발 키트 (R10E、32비트) 3GB
• Android SDK 1GB 미만
• Android SDK 셋업파일 (API 레벨 19혹은21) 5GB
• Java SE 개발키트(JDK) (7.0.550.13) 1GB
4. Windows 8.1이상에서 Hyper-V 지
원 유효화 필요
• Windows Phone 8.1 에뮬레이터
• Windows 10 Mobile 에뮬레이터
• Android Visual Studio 에뮬레이터
– 사용하기 위해
– Hyper-V란? X64기반의 컴퓨터에서 1대의 컴
퓨터에서 복수개의 가상환경을 실현 가능(단
윈도우 8부터 지원)
31. 소스코드 설명
• Fill Parent – 부모를 채운다
• Wrap Content – 허용되는 부모의 너비/높
이에 대해 최대한으로 채운다
• Match Parent – Fill Parent와 동일(OS버전
변경으로 추가됨)
32. 단위 설명
• DP – Density independent Pixels 스크린의 물리
적인 dp해상도에 독립적인 픽셀
• SP – Scale independent Pixels, 사용자의 폰트 사
이즈에 독립적인 크기. 폰트 크기에 사용 추천
• DPI –DP와 동일
• PX – Pixels, 스크린의 실제 픽셀
• IN – Inches, 스크린의 실제 크기(인치 단위)
• MM – Millimetres, 스크린의 실제 크기(mm 단위)
• PT – Points, 1/72 인치(스크린의 실제 크기 단위)
34. Relative Layout
1. Relative to Parent Container
2. Layout_AlignParentBottom – displays child at bottom of parent
3. Layout_AlignParentLeft – displays child on the left side of the
parent
4. Layout_AlignParentRight – displays child on the right side of
the parent
5. Layout_AlignParentTop – displays child at the top of the parent
6. Layout_CenterHorizontal – centers the child horizontally in the
parent
7. Layout_CenterInParent – centers the child both horizontally
and vertically in the parent
8. Layout_CenterVertical – centers the child vertically in the
parent
35. Relative Layout
9. Relative to Other View
10. Layout_Above – places the child above the
view
11. Layout_Below – places the child below the
view
12. Layout_ToLeftOf – places the element left
of the view
13. Layout_ToRightOf – places the element
right of the view
36. Relative Layout
14. Align with Other View
15. Layout_AlignBaseline – aligns baseline of the
new view with the baseline of specified view
16. Layout_AlignBottom – aligns bottom of the
new view with the bottom of the specified view
17. Layout_AlignLeft – aligns left of the new view
with the left of the specified view
18. Layout_AlignRight – aligns right of the new
view with the right of the specified view
19. Layout_AlignTop – aligns top of the new view
with the top of the specified view
47. Activity 작성
[Activity(Label = "XamarinBasic2", MainLauncher = false, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
var listView = FindViewById<ListView>(Resource.Id.listView1);
var data = new string[] { "월요일", "화요일", "수요일", "목요일", "금요일", "토요일", "
일요일" };
listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewTemplate1, data);
}
}
48. Entity 작성
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Gender { get; set; }
public int Age { get; set; }
}
50. 샘플 데이터 작성
private List<Person> CreateSampleData(int range)
{
var persons = new List<Person>();
for (int i = 1; i<=range; i++)
{
var person = new Person
{
FirstName = $"길동{i}",
LastName = $"홍{i}",
Gender = "남",
Age = 20 + i
};
persons.Add(person);
}
return persons;
}
51. Adapter클래스 작성
public class PeopleScreenAdapter : BaseAdapter<Person>
{
List<Person> p_items;
Activity p_context;
public PeopleScreenAdapter(Activity activity, List<Person> items)
{
p_items = items;
p_context = activity;
}
public override Person this[int position]
{
get
{
return p_items[position];
}
}
public override int Count
{
get
{
return p_items.Count;
}
}
52. public override long GetItemId(int position)
{
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = p_items[position];
View view = convertView;
if (view == null)
{
view = p_context.LayoutInflater.Inflate(Resource.Layout.ListViewTemplate2
, null);
}
view.FindViewById<TextView>(Resource.Id.textItem).Text =
$"{item.FirstName} {item.LastName} ({item.Gender}) : {item.Age}";
return view;
}
}
53. OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
var listView =
FindViewById<ListView>(Resource.Id.listView1);
var data = CreateSampleData(20);
//listView.Adapter = new ArrayAdapter(this,
Resource.Layout.ListViewTemplate1, data);
listView.Adapter = new PeopleScreenAdapter(this, data);
}
60. C# 이벤트 처리(다이얼로그에서)
• public event
EventHandler<OnSignUpEventArgs>
mOnSignUpComplete;
• mOnSignUpComplete.Invoke(this, new
OnSignUpEventArgs(mTxtFirstName.Text,
mTxtEmail.Text, mTxtPassword.Text));