Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid TabHost content not showing
    primarykey
    data
    text
    <p>I've created a TabHost and assigned 4 activity intents with tabs and these seems to work just fine. My only problem is that the activity content is not showing within the framelayout #tabcontent in my tabhost view.</p> <p>I've followed the official reference and scanned the internet for a solution but I can't see what the problem is.</p> <p>The Log.v("Activity", "Reports") is logged in ant, so it does execute the activity. Therefore I'm guessing its the setContentView() in my ReportsActivity that is causing the problem. But I'm new to this so I can't really tell. (There are no generated errors)</p> <p>This is my tabhost</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@android:id/tabhost" android:background="#FFFFFF"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF"&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5sp" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>This is how I add tabs in my TabActivity</p> <pre><code>// Glob Intent intent; TabHost tabHost = getTabHost(); TabHost.TabSpec spec; Resources res = getResources(); // Reports tab intent = new Intent().setClass(this, ReportsActivity.class); spec = tabHost.newTabSpec("reports") .setIndicator( res.getText(R.string.reports), res.getDrawable(R.drawable.reports)) .setContent(intent); tabHost.addTab(spec); </code></pre> <p>And this is my content activity (R.layout.reports = linearlayout with a textview)</p> <pre><code>public class ReportsActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reports); Log.v("Activity", "Reports"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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