Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement double Tabbed Activity in android?
    primarykey
    data
    text
    <p>I want to make an android application which has two tap in one view ,i.e, has upper tab and lower tab.</p> <p>According to selection of lower tab, I add the new tab host(for upper tab) in the tapcontent part of lower tab. But, upper tap doesn't go up, it stick to the lower tab.</p> <p>The implementation of upper tab is,</p> <pre><code>import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost; public class uppertab extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.upperlayout); TabHost tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, recommend_friend_simillar.class); spec = tabHost.newTabSpec("upper1").setIndicator("Upper1").setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, recommend_friend_new.class); spec = tabHost.newTabSpec("upper2").setIndicator("Upper2").setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, recommend_friend_favorite.class); spec = tabHost.newTabSpec("upper3").setIndicator("Upper3").setContent(intent); tabHost.addTab(spec); } } </code></pre> <p>xml for upper tap is,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/uppertabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TabWidget android:id="@+id/uppertabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;FrameLayout android:id="@+id/uppertabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>xml for lower tab is,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_alignParentBottom="true" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_above="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/FrameLayout&gt; &lt;/RelativeLayout&gt; &lt;/TabHost&gt; &lt;/LinearLayout&gt; </code></pre> <p>The result is shown below.</p> <pre><code>□□□□□□□□□□□□□□□□□□□□□□□□□□ □ □ □ □ □ □ □ □ □ □ □□□□□□□□□□□□□□□□□□□□□□□□□□ □ □ □ □ □upper1 □ upper2 □ upper3□ □□□□□□□□□□□□□□□□□□□□□□□□□□ □ lower1□lower2 □ lower3□ □□□□□□□□□□□□□□□□□□□□□□□□□□ </code></pre> <p>Of course, upper 3 taps should be stick to ceilling, like,</p> <pre><code>□□□□□□□□□□□□□□□□□□□□□□□□□□ □ □ □ □ □upper1 □ upper2 □ upper3□ □□□□□□□□□□□□□□□□□□□□□□□□□□ □ □ □ □ □ □ □ □ □ □ □□□□□□□□□□□□□□□□□□□□□□□□□□ □ lower1□ lower2 □ lower3□ □□□□□□□□□□□□□□□□□□□□□□□□□□ </code></pre> <p>(I got an advice that using activitygroup, but it doesn't work.)</p> <pre><code>import android.app.ActivityGroup; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost; public class uppertab extends ActivityGroup { private TabHost tabHost; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.upperlay); tabHost = (TabHost)findViewById(R.id.friendtabhost); tabHost.setup(getLocalActivityManager()); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(new Intent(this, tab1.class))); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2").setContent(new Intent(this, tab2.class))); tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3").setContent(new Intent(this, tab3.class))); </code></pre> <p>}</p> <p>}</p> <p>DDMS says that </p> <p>tabHost.setup(getLocalActivityManager());</p> <p>has a problem.</p> <p>What can I do :(?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload