简体   繁体   English

TabActivity和Android内的导航

[英]TabActivity and navigation inside Android

I have done TabActivity with this code: 我用以下代码完成了TabActivity

addTab(publication, "First", My_Files.class);
addTab(shop, "Second", Others.class); 

private void addTab(String labelId, int drawableId, Class<?> c)
{
    TabHost tabHost = getTabHost();  // The activity TabHost

    Intent intent = new Intent(this, c);
    TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); 

    View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
    TextView title = (TextView) tabIndicator.findViewById(R.id.title);
    title.setText(labelId);
    ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
    icon.setImageResource(drawableId);

    spec.setIndicator(tabIndicator);
    spec.setContent(intent);
    tabHost.addTab(spec);
}

In these first and second tabs, I have ListView s with some context where user press it and it goes to other Activity with this code: 在这些第一个和第二个选项卡中,我具有ListView带有一些上下文,用户可以在其中按下该代码,并使用以下代码转到其他Activity

    Intent intent = new Intent("android.app.reader.FILES");  
    intent.putExtra("publicatonName", "fileName");
    startActivity(intent);

But there disappear my TabActivity , but I still want to use it like iPhone UITabBar with UINavigationController 但也有消失我TabActivity ,但我仍然想使用它像iPhone UITabBarUINavigationController

So now I am thinking that when I go to other Activity I need to change current TabActivity button class target to current and somehow my Tab Bar Activity should be visible. 所以现在我在想,当我转到其他“ Activity我需要将当前的TabActivity按钮类目标更改为“当前”,并且以某种方式应该可以看到我的“ Tab Bar Activity

Maybe someone could help me. 也许有人可以帮助我。

Thanks. 谢谢。

ActivityGroup, which will be the container of your other Activities. ActivityGroup,它将成为您其他Activity的容器。 When the user clicks one of the buttons, you'd get a reference to the LocalActivityManager, and use it to start, and embed the inner activity. 当用户单击其中一个按钮时,您将获得对LocalActivityManager的引用,并使用它来启动并嵌入内部活动。 get some experience from here and also 得到一些经验在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM