MEMBUAT MOBILE APPLICATION MENGGUNAKAN XAMARIN
Untuk pengaplikasian mobile application ini berupa sebuah aplikasi sederhana android yaitu aplikasi Increment dan Decremen
Tampilan aplikasi sederhana android yang saya buat sebagai berikut
Source code nya dapat dilihat sebagai berikutMain
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TextView
- android:text="0"
- android:textSize="50sp"
- android:gravity="center"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/txtNumber"
- android:layout_marginBottom="20dp"
- android:layout_marginTop="20dp" />
- <Button
- android:text="Increment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/btnIncrement" />
- <Button
- android:text="Decrement"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/btnDecrement" />
- </LinearLayout>
MainActivity.cs
- using Android.App;
- using Android.Widget;
- using Android.OS;
- namespace XamarinTut
- {
- [Activity(Label = "XamarinTut", MainLauncher = true, Icon = "@drawable/icon")]
- public class MainActivity : Activity
- {
- TextView txtNumber;
- int number;
- protected override void OnCreate(Bundle bundle)
- {
- base.OnCreate(bundle);
- // Set our view from the "main" layout resource
- SetContentView (Resource.Layout.Main);
- txtNumber = FindViewById<TextView>(Resource.Id.txtNumber);
- FindViewById<Button>(Resource.Id.btnIncrement).Click += (o, e) =>
- txtNumber.Text = (++number).ToString();
- FindViewById<Button>(Resource.Id.btnDecrement).Click += (o, e) =>
- txtNumber.Text = (--number).ToString();
- }
- }
- }
Untuk referensi saya menggunakan link youtube berikut
Tidak ada komentar:
Posting Komentar