Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:39:32+00:00 2026-06-17T04:39:32+00:00

Update: The compile error is resolved and I found some things I didn’t do

  • 0

Update:

The compile error is resolved and I found some things I didn’t do right orgianlly based off the example I was following and corrected them. However when I try to run the code I get the following error. When I line by through the code I have noticed that the createTabContent inside the NewTab.setContent doesn’t execute because my breakpoint in there is never tripped.

01-12 10:11:21.285: E/AndroidRuntime(14528): FATAL EXCEPTION: main
01-12 10:11:21.285: E/AndroidRuntime(14528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jackman.universalav/com.jackman.universalav.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.os.Handler.dispatchMessage(Handler.java:99)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.os.Looper.loop(Looper.java:137)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-12 10:11:21.285: E/AndroidRuntime(14528): at java.lang.reflect.Method.invokeNative(Native Method)
01-12 10:11:21.285: E/AndroidRuntime(14528): at java.lang.reflect.Method.invoke(Method.java:511)
01-12 10:11:21.285: E/AndroidRuntime(14528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
01-12 10:11:21.285: E/AndroidRuntime(14528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
01-12 10:11:21.285: E/AndroidRuntime(14528): at dalvik.system.NativeStart.main(Native Method)
01-12 10:11:21.285: E/AndroidRuntime(14528): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.content.res.Resources.getValue(Resources.java:1026)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2131)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.content.res.Resources.getLayout(Resources.java:865)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.widget.TabHost$LabelIndicatorStrategy.createIndicatorView(TabHost.java:554)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.widget.TabHost.addTab(TabHost.java:234)
01-12 10:11:21.285: E/AndroidRuntime(14528): at com.jackman.universalav.MainActivity.onCreate(MainActivity.java:71)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.Activity.performCreate(Activity.java:5191)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
01-12 10:11:21.285: E/AndroidRuntime(14528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-12 10:11:21.285: E/AndroidRuntime(14528): ... 11 more

The updated code is:

public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Create the tab host that contains the tab widget that contains the tabs
        TabHost Tabs = new TabHost(this);
        Tabs.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        //Create the tab widget  container
        TabWidget TabWidget = new TabWidget(this);
        TabWidget.setId(android.R.id.tabs);
        Tabs.addView(TabWidget, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        //the tab host needs a frame layout for the views associated with each visible tab
        FrameLayout frameLayout = new FrameLayout(this);
        frameLayout.setId(android.R.id.tabcontent);
        frameLayout.setPadding(0, 65, 0, 0);
        Tabs.addView(frameLayout, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tabs.setup();
        //Create the tabs
        DatabaseHelper dbHelper = new DatabaseHelper(this);
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        String dbQuery = "SELECT * FROM " + dbHelper.System_Table + " AS s JOIN " + dbHelper.Devices_Table + " AS d ON s." + dbHelper.Attribute_Device_ID +
            " = d." + dbHelper.Attribute_Device_ID + ";";
        Cursor c = db.rawQuery(dbQuery, null);
        if (c.getCount() > 0)
        {
            while (c.moveToNext())
            {
                  int iColumnDeviceType = c.getColumnIndex(dbHelper.Attribute_Device_Type);
                  int iColumnDeviceName = c.getColumnIndex(dbHelper.Attribute_Device_Name);
                  final String DeviceType = c.getString(iColumnDeviceType);
                  String DeviceName = c.getString(iColumnDeviceName);
                  String DeviceNameLabel = DeviceName.replaceAll(" ", "");
                  TabSpec NewTab = Tabs.newTabSpec("tab" + DeviceNameLabel);
                  NewTab.setIndicator(DeviceNameLabel);
                  NewTab.setContent(new TabHost.TabContentFactory()
                  {
                    public View createTabContent(String tag)
                    {
                        LinearLayout ll = new LinearLayout(MainActivity.this);
                        LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
                        ll.setLayoutParams(params);
                        ll.setOrientation(LinearLayout.VERTICAL);
                        if (DeviceType == "Receiver")
                        {

                        }
                        else if (DeviceType == "Video Player")
                        {

                        }
                        return ll;
                     }
                   });
                   Tabs.addTab(NewTab);
             }
        }
    }
}

End Update

Orginal question below:

I haven’t got to the point where this routine is finished yet.

I was trying to follow a sample of code from this link. http://www.pocketmagic.net/2010/01/android-dynamic-tab-control/

However when I attempt to create a linearlayout for the tab being created the compiler freaks out on me. I’m not sure why it is throwing the error. It’s like the object I made one line ago doesn’t exist.

The returned errors are:

Multiple markers at this line
- Syntax error on token(s), misplaced construct(s)
- Syntax error on token "params", VariableDeclaratorId expected after this token

Anyways the code is below. Can anyone see what I am doing wrong?

//Create the tab host that contains the tab widget that contains the tabs
TabHost Tabs = new TabHost(this);
Tabs.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
//Create the tab widget  container
TabWidget TabWidget = new TabWidget(this);
TabWidget.setId(android.R.id.tabs);
Tabs.addView(TabWidget, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
Tabs.setup();
//Create the tabs
DatabaseHelper dbHelper = new DatabaseHelper(this);
SQLiteDatabase db = dbHelper.getWritableDatabase();
String dbQuery = "SELECT * FROM " + dbHelper.System_Table + " AS s JOIN " +
    dbHelper.Devices_Table + " AS d ON s." + dbHelper.Attribute_Device_ID +
    " = d." + dbHelper.Attribute_Device_ID + ";";
Cursor c = db.rawQuery(dbQuery, null);
if (c.getCount() > 0)
{
    while (c.moveToNext())
    {
        int iColumnDeviceType = c.getColumnIndex(dbHelper.Attribute_Device_Type);
        int iColumnDeviceName = c.getColumnIndex(dbHelper.Attribute_Device_Name);
        final String DeviceType = c.getString(iColumnDeviceType);
        String DeviceName = c.getString(iColumnDeviceName);
        String DeviceNameLabel = DeviceName.replaceAll(" ", "");
        TabSpec NewTab = Tabs.newTabSpec("tab" + DeviceNameLabel);
        NewTab.setIndicator(DeviceName);
        NewTab.setContent(new TabHost.TabContentFactory()
        {
            LinearLayout ll = new LinearLayout(MainActivity.this);
            LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            ll.setLayoutParams(params); //this line has both of the errors
            public View createTabContent(String tag)
            {
                    if (DeviceType == "Receiver")
                    {

                    }
                    else if (DeviceType == "Video Player")
                    {

                    }
                    return null; //place holder until I finish the routine
                }
            });
            Tabs.addTab(NewTab);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:39:33+00:00Added an answer on June 17, 2026 at 4:39 am

    I figured out the issue after much trial and error and googling an extensive ammount of examples.

    First I gave up attempting to create the tab widget and the frame layout through java instead of xml for the activity..

    In my activities layout xml file I added a tab control and in the xml view deleted the tabs leaving the xml code looking like this.

    <RelativeLayout 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"
    tools:context=".MainActivity" >
    
        <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    
            <LinearLayout
            android:id="@+id/MainLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>
    
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
    
    
                </FrameLayout>
            </LinearLayout>
        </TabHost>
    </RelativeLayout>
    

    Then in the java file for the activity I updated the oncreate routine to be this.

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    //Create the tabs
    TabHost Tabs = (TabHost) findViewById(android.R.id.tabhost);
    Tabs.setup();
    DatabaseHelper dbHelper = new DatabaseHelper(this);
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    String dbQuery = "SELECT * FROM " + dbHelper.System_Table + " AS s JOIN " +
        dbHelper.Devices_Table + " AS d ON s." + dbHelper.Attribute_Device_ID +
        " = d." + dbHelper.Attribute_Device_ID + ";";
    Cursor c = db.rawQuery(dbQuery, null);
    int Count = 0;
    if (c.getCount() > 0)
    {
        while (c.moveToNext())
        {
            Count = Count + 1;
            int iColumnDeviceType = c.getColumnIndex(dbHelper.Attribute_Device_Type);
            int iColumnDeviceName = c.getColumnIndex(dbHelper.Attribute_Device_Name);
            final String DeviceType = c.getString(iColumnDeviceType);
            final String DeviceName = c.getString(iColumnDeviceName);
            final String DeviceNameLabel = DeviceName.replaceAll(" ", "");
            Log.d("Creating Tab", "TabSpec: tab" + DeviceNameLabel);
            Log.d("Creating Tab", "Indicator: " + DeviceName);
            final TabSpec NewTab = Tabs.newTabSpec("tab" + DeviceNameLabel);
            NewTab.setIndicator(DeviceName);
            NewTab.setContent(new TabHost.TabContentFactory()
            {
                @Override
                public View createTabContent(String tag)
                {
                    LinearLayout ll = new LinearLayout(MainActivity.this);
                    LayoutParams params = new LinearLayout.LayoutParams(
                        LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
                    ll.setLayoutParams(params);
                    ll.setOrientation(LinearLayout.VERTICAL);
                    if (DeviceType.equals("Receiver"))
                    {
                        final Button btnVolumeUp = new Button(MainActivity.this);
                        btnVolumeUp.setText("Volume Up");
                        btnVolumeUp.setLayoutParams(new LayoutParams(
                            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                        btnVolumeUp.setGravity(Gravity.LEFT);
                        ll.addView(btnVolumeUp);
                    }
                    else if (DeviceType.equals("Video Player"))
                    {
                        final Button btnPlay = new Button(MainActivity.this);
                        btnPlay.setText("Play");
                        btnPlay.setLayoutParams(new LayoutParams(
                            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                        btnPlay.setGravity(Gravity.LEFT);
                        ll.addView(btnPlay);
                    }
                    return ll;
                }
            });
    
            Tabs.addTab(NewTab);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: I'm getting this error: (No route matches /docs/index.html... ) when accessing admin.example.com/docs/index.html The
For some reason I'm experiencing the following Maven error, this was working before so
Update : I found almost exact similar question , yet it has slightly different
UPDATE: All Issues Resolved Using Bart's suggestions for Issue 2 & 3 ( first
I am trying to compile a maven project, but I systematically get the following
Update: Tried November CTP release. Same error message. Forgot to mention that this server
I'm trying to compile unit test (boost) on Linux but compiler thows an error.
I'm getting R cannot be resolved error. I read R cannot be resolved -
Update: Is there a way to achieve what I'm trying to do in an
update: I mistyped 2 variables...so embarrassing. thanks everyone for the effort! sorry i find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.