【发布时间】:2014-01-05 03:11:19
【问题描述】:
如何为每个选项卡设置 xml 布局?
创建每个选项卡的代码
private void CreateTab(Type activityType, string tag, string label, int drawableId)
{
TabHost.TabSpec spec;
var intent = new Intent(this, activityType);
intent.AddFlags(ActivityFlags.NewTask);
spec = TabHost.NewTabSpec(tag);
var drawableIcon = Resources.GetDrawable(drawableId);
spec.SetIndicator("", drawableIcon);
spec.SetContent(intent);
TabHost.AddTab(spec);
}
这是第一个标签活动的代码
[Activity(Label = "My Activity")]
public class WhatsOnActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//TextView textview = new TextView(this); // working
//textview.Text = "This is Whats on activity tab";
//SetContentView(textview);
SetContentView(Resource.Layout.Feed); // not working
}
}
触发异常。我怎样才能让它工作?
请帮忙, 谢谢
【问题讨论】: