Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication crashing at TabActivity
    primarykey
    data
    text
    <p>Hi I'm a real novice at android and really getting desperate at this apparently simple attempt with TabActivity. The application crashes with the "stopped unexpectedly" error. I've tried to run code from online tutorials but same error every time. So here is the embarrassingly simple code.</p> <pre><code>import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost; public class MainLanding extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainlandingtab); TabHost mainLandingTab = getTabHost(); TabHost.TabSpec spec; Intent intent = new Intent().setClass(this, AccountActivity.class); spec = mainLandingTab.newTabSpec("account"); spec.setContent(intent); spec.setIndicator("Account"); mainLandingTab.addTab(spec); mainLandingTab.getTabWidget().getChildAt(0).getLayoutParams().height = 40; intent = new Intent().setClass(this, ProfileActivity.class); spec.setContent(intent); spec.setIndicator("Profile"); mainLandingTab.addTab(spec); mainLandingTab.getTabWidget().getChildAt(1).getLayoutParams().height = 40; intent = new Intent().setClass(this, SocialActivity.class); spec.setContent(intent); spec.setIndicator("Social"); mainLandingTab.addTab(spec); mainLandingTab.getTabWidget().getChildAt(2).getLayoutParams().height = 40; } } </code></pre> <p>Here is the mainlandingtab.xml file.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tabHost" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;TabWidget android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@android:id/tabs" /&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@android:id/tabcontent"/&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>And the manifest file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mobile.banking" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name"&gt; &lt;activity android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:name=".StartupActivity"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".MainLanding" /&gt; &lt;activity android:name=".AccountActivity" /&gt; &lt;activity android:name=".ProfileActivity" /&gt; &lt;activity android:name=".SocialActivity" /&gt; &lt;activity android:name=".SignInActivity"&gt;&lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>There are other activities also in the application which to run fine but when MainLanding class is called, it crashes. </p> <p>The logcat error says: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'</p> <p>I have no idea what's wrong with this code. Please help!!</p>
    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.
 

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