Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid Tabs layout error
    text
    copied!<p>I am trying to make tabs layout. I am using tutorial code (below) but it doesn't work. LogCat gives this error:</p> <p><em>04-19 19:02:16.297: ERROR/AndroidRuntime(455): java.lang.RuntimeException: Unable to start activity ComponentInfo{jusbrz.bakalauras/jusbrz.bakalauras.FilesTabsActivity}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'</em></p> <p>I added new activitys to manifest.</p> <p>XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TabWidget android:id="@+id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;/TabWidget&gt; &lt;FrameLayout android:id="@+id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>Using this code in main activity:</p> <pre><code>package jusbrz.bakalauras; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost; public class FilesTabsActivity extends TabActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.files_tabs_layout); TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, AllFilesTabActivity.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("Visi").setIndicator("Visi").setContent(intent); tabHost.addTab(spec); } } </code></pre> <p>So where might be the problem?</p> <p><strong>EDITED</strong></p> <pre><code>import android.app.TabActivity; import android.os.Bundle; public class AllFilesTabActivity extends TabActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_files_tab_layout); } } </code></pre>
 

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