Tugas 5 PBKK - Mobile Application Menggunakan Xamarin
Tutorial Cara Membuat Aplikasi Menggunakan Xamarin
Step:
1. Buka Aplikasi Visual Studio
2. Install Mobile development with .NET
3. Pilih Create a new project dan pilih Mobile App (Xamarin.Forms)
4. Atur nama aplikasi dan lokasi penyimpanan
5. Pilih Template - Blank
6. Ubah kode pada MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AwesomeApp.MainPage">
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<Button Text="Click Me!" Clicked="ClickCounter"/>
<Label Text="Hello, World!" FontSize="Title" Padding="30,10,30,10"/>
<Label Text="Mobile Development With Xamarin" FontSize="16" Padding="30,0,30,0"/>
<Label FontSize="16" Padding="30,24,30,0">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="Learn more at "/>
<Span Text="https://kresnaadhipramana.blogspot.com/" FontAttributes="Bold"/>
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ContentPage>
7. Ubah kode pada MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace AwesomeApp
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
int count = 0;
void ClickCounter(object sender, System.EventArgs e)
{
count++;
((Button)sender).Text = $"You clicked {count} times.";
}
}
}
8. Setup Emulator
9. Run aplikasi di emulator yang sudah dipersiapkan sebelumnya
Source Code
https://github.com/KresnaAP/hello-world-xamarin
Referensi
https://dotnet.microsoft.com/learn/xamarin/hello-world-tutorial/install
Comments
Post a Comment