我在我的项目中使用 tabhost
现在我有以下问题,当我点击选项卡 1 时,它启动了一个正确的选项卡 1 的新活动,它加载了我的列表视图也很完美,但是当我点击列表视图项目时,它也应该开始一个新活动,但它在空白屏幕中打开而不是在 tabhost/framelayout
这是我的代码示例,希望您能给我建议,非常感谢
列表视图活动/选项卡 1
[Activity(Label = "Pagina")]
public class Paginas : Activity
{
ListView listView;
CMS.APPS CMS = new CMS.APPS();
List<CMS.Pages> ListPages;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Core.Context = this;
SetContentView(Resource.Layout.Paginas);
ListPages = CMS.GetPagesAndroid(Core.AdministratieID, null, Core.UserID, null, null, null, null, null, null, null, null).ToList();
listView = FindViewById<ListView>(Resource.Id.ListViewPaginas);
listView.Adapter = new PagesAdapter(this, ListPages);
listView.ChoiceMode = ChoiceMode.Single;
listView.ItemClick += OnListItemClick;
}
protected void OnListItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
{
var listView = sender as ListView;
var t = ListPages[e.Position];
var CMSPage = new Intent(this, typeof(Handler));
CMSPage.PutExtra("PAG_ID", t.PAG_ID.ToString());
StartActivity(CMSPage);
//Android.Widget.Toast.MakeText(this, t.PAG_TITLE, Android.Widget.ToastLength.Short).Show();
}
}
我现在要做的是开始一个新的活动 CMSPage typeof Handler 它给我一个空白屏幕而不是打开它来代替 Pagina/Tab 1
编辑:主屏幕上的 Tabhost 代码:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Homescreen);
Core.Context = this;
CreateTab(typeof(Paginas), "Pagina's", "Pagina's", Resource.Drawable._Pagina);
CreateTab(typeof(Profiel), "Profiel", "Profiel", Resource.Drawable._Profiel);
}
private void CreateTab(Type activityType, string tag, string label, int? drawableId = null)
{
var intent = new Intent(this, activityType);
intent.AddFlags(ActivityFlags.NewTask);
var spec = TabHost.NewTabSpec(tag);
if (drawableId > 0)
{
var drawableIcon = Resources.GetDrawable(drawableId.Value);
spec.SetIndicator(label, drawableIcon);
}
else
{
spec.SetIndicator(label, null);
}
spec.SetContent(intent);
TabHost.AddTab(spec);
}