1) Open MS Visual Studio 2019
2) File-> New Project->C#->Android->Android App (Xamarin) Blank App (3) Launch the app
You can run the app on your android phone via usb cable
or
Open Android Studio and launch the emulator.
Now you will see that emulator on the Start arrow:
4) Now modify the ui that was created, first stop the app (red square button)
Goto Resources->Layout->Main.axml
- Add a linear (vertical) layout to replay the Relative Layout (see the xml below)
- Add a TextView
- Add a EditView
- Add a button
5) Goto Mainactivity.cs
add code like this after line 17:
Button button = FindViewById<Button>(Resource.Id.button1);
TextView tvResult = FindViewById<TextView>(Resource.Id.textView1);
EditText etName = FindViewById<EditText>(Resource.Id.editText1);
button.Click += delegate {
tvResult.Text = "Hello " + etName.Text;
};
My activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Me" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/editText1"
android:hint="Your Name" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1" />
</LinearLayout>