废话不说直接上干货:
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="跳转"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button2" />
<EditText
android:id="@+id/et_StartTime"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App1
{
[Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//无标题栏位
this.RequestWindowFeature(WindowFeatures.DefaultFeatures);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Button button = FindViewById<Button>(Resource.Id.button2);
button.Click += button_Click; ;
}
void button_Click(object sender, EventArgs e)
{
StartActivity(new Intent(this, typeof(Activity1)));
}
}
}
layout1.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<Button
android:text="返回Main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1" />
</LinearLayout>
Activity1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Text.Method;
using Android.Text.Style;
using Android.Views;
using Android.Widget;
namespace App1
{
[Activity(Label = "Activity1")]
public class Activity1 : Activity, View.IOnClickListener
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.layout1);
Button button = FindViewById<Button>(Resource.Id.button1);
button.SetOnClickListener(this);
}
public void OnClick(View v)
{
Finish();
}
}
}
源码,可直接运行