我想在片段中添加tabhost,但无论我尝试什么,我都无法插入它。我可能会在这里错过一些基础知识。下面是我的类TabFragment的代码。它返回一个视图。如何在片段中添加tabhost
public class TabFragment extends Fragment{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
private TabHost mTabHost;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.tabmain, container, false);
mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
mTabHost.setup();//very important to call this
TabHost.TabSpec tab = mTabHost.newTabSpec("my tab content");
tab.setIndicator("my tab content");
mTabHost.addTab(tab);
return view;
}
}
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/此链接可能有帮助 – Triode 2012-03-02 06:58:54
不,它不。他们正在使用片段制作制表符,那不是我的要求加我的片段之一必须是静态的。我绝对需要以某种方式插入tabhost – sohil 2012-03-03 04:04:06
@sohil你有没有得到解决..我卡在相同..你可以帮助..在这里检查http://stackoverflow.com/questions/28106944/how-to-add-tabhost-与导航抽屉?noredirect = 1个#comment44592501_28106944? – 2015-01-23 13:37:41