ActionBarを使用した単純なレイアウトがあり、ユーザーがタブを選択したときにメッセージを表示したいと思います。ActionBar.ITabListenerとOnTabSelectedを実装しましたが、機能しません。コードの何が問題になっていますか?コードは次のとおりです。
namespace ICSTabs
{
[Activity (Label = "ICSTabs", MainLauncher = true)]
public class Activity1 : Activity, ActionBar.ITabListener
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
ActionBar bar = ActionBar;
bar.NavigationMode = ActionBarNavigationMode.Tabs;
bar.AddTab (bar.NewTab ().SetText ("TEXT1")
.SetTabListener (this));
bar.AddTab (bar.NewTab ().SetText ("TEXT2")
.SetTabListener (this));
bar.AddTab (bar.NewTab ().SetText ("TEXT3")
.SetTabListener (this));
}
public void OnTabSelected (ActionBar.Tab tab, FragmentTransaction ft)
{
Toast.MakeText(this, "Some text", ToastLength.Short);
}
public void OnTabUnselected (ActionBar.Tab tab, FragmentTransaction ft)
{
}
public void OnTabReselected (ActionBar.Tab tab, FragmentTransaction ft)
{
}
}
}