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

  • Home
  • SEARCH
  • 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 391019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:01:15+00:00 2026-05-12T16:01:15+00:00

I never designed UIs (more of a middleware guy) before so I apologize if

  • 0

I never designed UIs (more of a middleware guy) before so I apologize if the question is stupid. I am designing a UI to look something like the following:


ImageView ImageView

TabHost

Tab 0 —— Tab 1 —— Tab 2

—–INSIDE EACH TAB—–

TextView

ListView

– Consists of ImageView TextView


The problem is I think I am following a very inefficient way of doing the whole stuff. The onCreate method is as follows:

CODE:

public void onCreate(Bundle savedInstanceState) { 

          super.onCreate(savedInstanceState); 
          setContentView(R.layout.main); 

          TabHost mTabHost = getTabHost(); 

          Drawable Tab1Icon = getResources().getDrawable(R.drawable.tab1_icon); 
          Drawable Tab2Icon = getResources().getDrawable(R.drawable.tab2_icon); 
          Drawable Tab3Icon = getResources().getDrawable(R.drawable.tab3_icon); 

          mTabHost.addTab(mTabHost.newTabSpec("Tab1").setIndicator("Tab 1", Tab1Icon).setContent(new Intent(this, Tab1.class))); 
          mTabHost.addTab(mTabHost.newTabSpec("Tab2").setIndicator("Tab 2", Tab1Icon).setContent(new Intent(this, Tab2.class))); 
          mTabHost.addTab(mTabHost.newTabSpec("Tab3").setIndicator("Tab 3", Tab1Icon).setContent(new Intent(this, Tab3.class))); 

          mTabHost.setCurrentTab(0); 
     } 

This program crashes on CupCake (v1.5) complaining about StackOverflowException but runs well on Donut (v1.6). This is my main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/application_background" 
    > 

    <TableLayout 
               android:id="@+id/TableLayout01" 
               android:layout_width="fill_parent" 
               android:layout_height="fill_parent" 
               android:stretchColumns="0" 
               android:background="@color/application_background"> 

          <TableRow> 
               <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:orientation="horizontal" 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent"> 
               <ImageView id="@+id/picview1" 
                  android:layout_width="wrap_content" 
                  android:layout_height="wrap_content" 
                  android:src="@drawable/leftlogo" 
                  android:paddingRight="105sp" 
                /> 
                <Button 
                    android:id="@+id/picview2" 
                   android:layout_width="wrap_content" 
                   android:layout_height="wrap_content" 
                   android:background="@drawable/rightlogo" 
                   /> 
          </LinearLayout> 
          </TableRow> 

          <TableRow> 
               <TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
                   android:id="@android:id/tabhost" 
                   android:layout_width="fill_parent" 
                   android:layout_height="fill_parent"> 
                   <LinearLayout 
                       android:orientation="vertical" 
                       android:layout_width="fill_parent" 
                       android:layout_height="fill_parent"> 
                       <TabWidget 
                           android:id="@android:id/tabs" 
                           android:layout_width="fill_parent" 
                           android:layout_height="wrap_content" /> 
                       <FrameLayout 
                           android:id="@android:id/tabcontent" 
                           android:layout_width="fill_parent" 
                           android:layout_height="fill_parent"> 

                    </FrameLayout> 
                   </LinearLayout> 
               </TabHost> 
          </TableRow> 

     </TableLayout> 
</LinearLayout> 

Any suggestions regarding the design please?

Thanks

  • 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-05-12T16:01:16+00:00Added an answer on May 12, 2026 at 4:01 pm
    1. If you are getting StackOverflowExceptions, your UI is too complex. Fire up hierarchyviewer and find ways to remove some layers.
    2. One way to simplify everything and remove layers is to supply the tab contents as Views, not Intents pointing to Activities.
    3. You can just pass the R.drawable ID of the icon to setIndicator().
    4. You should not have the TableLayout inside a LinearLayout (why bother with the LinearLayout?) or a LinearLayout inside of a TableRow (TableRow is a LinearLayout, for all intents and purposes). Please consider dumping the entire TableLayout/TableRow/LinearLayout stuff and just use a single RelativeLayout.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.