您還沒有指定您希望這些按鈕可以顯示用戶;
SetContentView
方法用於通過'膨脹'佈局文件來創建活動的視圖。您應該通過此佈局文件而不是代碼創建大部分視圖(例如按鈕),特別是如果您不熟悉C#,Android或一般編程時。
下面是一些axml讓你開始:
<?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">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnOff" />
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnOn" />
</LinearLayout>
而且你應該在你的Pudisoo_TabSelected1
方法使用的代碼:儘管這整個的做法實際上是不正確
private void Pudisoo_TabSelected1(object sender, ActionBar.TabEventArgs e)
{
SetContentView(Resource.Layout.filenamehere);
Button btnOn = FindViewById<Button> (Resource.Id.btnOn);
Button btnOff = FindViewById<Button> (Resource.Id.btnOff);
btnOff.Click += Btnoff_Click;
btnOn.Click += Btnon_Click1;
}
(你應該使用碎片來達到這種效果),它至少會做你想做的事情,並且可以作爲一個起點,而你變得更加舒適。
你在哪裏試圖讓按鈕出現?你可以發佈你的代碼活動? – dylansturg