java - Android Tabhost show fragment overlay -


i having problem using tabhost, when starting app, shows main fragmentactivity, shows me fragment should visible when tab selected

main.java extending fragmentactivity

mtabhost = (fragmenttabhost)findviewbyid(android.r.id.tabhost);         mtabhost.setup(this, getsupportfragmentmanager(), r.id.realtabcontent);         mtabhost.addtab(mtabhost.newtabspec("tab1").setindicator("tab1"),myfragment.class, null); 

myfragment.java

public class myfragment extends fragment {     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate){         return inflater.inflate(r.layout.fragmentlayout, container, false);      }    } 

main.xml

<android.support.v4.app.fragmenttabhost     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@android:id/tabhost"     android:layout_width="match_parent"     android:background="@color/black"     android:layout_height="match_parent">  <linearlayout     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent">      <tabwidget         android:id="@android:id/tabs"          android:orientation="horizontal"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_weight="0"/>      <framelayout         android:id="@android:id/tabcontent"         android:layout_width="0dp"         android:layout_height="0dp"         android:layout_weight="0"/>      <framelayout         android:id="@+id/realtabcontent"         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1"/>  </linearlayout> </android.support.v4.app.fragmenttabhost> 

fragmentlayout.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical"         tools:context=".devicefragment" >      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="text" />  </linearlayout> 

did forgot something. right can see black background color main fragment activity, textlabel fragment shown @ start. doesn't show me tabhost tabbutton, fragment's tabbutton. followed https://github.com/clarezhang/android-fragmenttabhost-demo commented out of code, , copied in. still doesn't show me tabhost without fragment lying on top of it.

what did wrong, suggestions?


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -