PBKK : Tugas 5 - Mobile Apps dengan Xamarin
Tugas 5 - Mobile Apps dengan Xamarin
- Pertama buat project Mobile Apps(Xamarin.Forms) menggunakan bahasa C#
- Konfigurasi Project dengan mengisi nama project, kemudian pilih template yang digunakan adalah blank dan Android dan IOS sudah tercentang.
- Pada kesempatan ini saya akan menggunakan device asli. Untuk panduanya bisa dibaca disini.
- Ketika USB Debugging sudah berhasil dikonfigurasi jalankan aplikasi. Maka pada handphone akan meminta untuk mengisntall aplikasi. Dan akan membuka aplikasi dengan tampilan awal sebagai berikut.
- Ubah Kode MainPage.xaml menjadi seperti berikut maka tampilan akan berubahThis 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
<?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="HelloWorld.MainPage"> <StackLayout> <Frame BackgroundColor="DeepPink" Padding="24" CornerRadius="0"> <Label Text="Welcome Rohman to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> </Frame> <Button Text="Click Me" Clicked="Handle_Clicked" /> <Label Text="Hello World !!!" FontSize="40" Padding="30,10,30,10"/> <Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/> <Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try!" 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://aka.ms/xamarin-quickstart" FontAttributes="Bold"/> </FormattedString.Spans> </FormattedString> </Label.FormattedText> </Label> <Label Padding="30,24,30,0"> <Label.FormattedText> <FormattedString > <FormattedString.Spans> <Span FontSize="24" Text="Abdur Rohman 05111840000100" FontAttributes="Bold" TextColor="LightBlue"/> </FormattedString.Spans> </FormattedString> </Label.FormattedText> </Label> </StackLayout> </ContentPage> - Ubah Kode MainPage.xaml.cs menjadi seperti berikut maka button akan bisa menghitung jumlah clickThis 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
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; namespace HelloWorld { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } int count = 0; void Handle_Clicked(object sender, System.EventArgs e) { count++; ((Button)sender).Text = $"You clicked {count} times."; } } }
Komentar
Posting Komentar