Android Error : No Tab Known For Null Tag
I need a fixed area (around 20%) at top and then 3 tabs below it. The xml is mylist.xml Copy
Fragment Class:
publicclassMyListFragmentextendsFragment {
private FragmentTabHost mTabHost;
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stubViewrootView= inflater.inflate(R.layout.activity_main, container,
false);
TextViewname= (TextView) rootView.findViewById(R.id.list_name);
TextViewspec= (TextView) rootView.findViewById(R.id.list_spec);
TextViewusers= (TextView) rootView.findViewById(R.id.list_user);
mTabHost = (FragmentTabHost)rootView.findViewById(R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(),
R.id.list_realtabcontent);
Bundlearg1=newBundle();
arg1.putInt("Tab1", 1);
mTabHost.addTab(
mTabHost.newTabSpec("Tab1").setIndicator("Tab1",
getResources().getDrawable(R.drawable.tab_chat_unselected)),
TabFragment.class, arg1);
Bundlearg2=newBundle();
arg2.putInt("Tab2", 2);
mTabHost.addTab(
mTabHost.newTabSpec("Tab2").setIndicator("Tab2",
getResources().getDrawable(R.drawable.tab_chat_unselected)),
TabFragment.class, arg2);
Bundlearg3=newBundle();
arg3.putInt("Tab3", 3);
mTabHost.addTab(
mTabHost.newTabSpec("Tab3").setIndicator("Tab3",
getResources().getDrawable(R.drawable.tab_chat_unselected)),
TabFragment.class, arg3);
return rootView;
}
Solution 2:
You can use this library. Having a Tabs with Navigation Drawers is the not provided directly. If u want to have tabs in fragment just like google-play music. I advice you to use this library.
Just create the navigation drawer in the same way we create and jsut properly intergrate it. Thats set very simple.
The Solution provided by @Haresh may work. But if it doesn't apply the link I have provided will definetly work. I have used that library in my project refer link1 and link2
Hope it helps
Solution 3:
Try this way,hope this will help you to solve your problem.
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="0.20"></LinearLayout><android.support.v4.app.FragmentTabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="0.80"android:background="#CCF8FB" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:orientation="vertical" ><TextViewandroid:id="@+id/loc_playlist_locname"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="0.2" /><FrameLayoutandroid:id="@+id/playlist_realtabcontent"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="0.1" /><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="0dip"android:layout_height="0dip"android:layout_weight="0" /></LinearLayout></android.support.v4.app.FragmentTabHost></LinearLayout>
Post a Comment for "Android Error : No Tab Known For Null Tag"