Hi all,
same problem here..
I've been trying to debug this problem all day long and can't seem to
find the breakthrough. I'm using tabhosts to create tabs on the main
screen, then I try to put list inside the other tab.To achieve that,
I'm using setContent(Intent e ) methods.. hoping that the list will be
contained on the tab.
Here's my errorr I'm getting: Did you forget to call 'public void setup
(LocalActivityManager activityGroup)'?
But as you see on the codes below, I already call tabs.setup();

So here's the structure of my program:

public class myHome extends  TabActivity {
@Override
        public void onCreate(Bundle home) {
                super.onCreate(home);
                // call the home screen
                try {
                        setContentView(R.layout.home);
                } catch (Exception e) {
                        Log.e("ERROR0001", e.getMessage());
                        // TODO: handle exception
                }

                // do the actual work here...

                // manage tab
                try {
                        final TabHost tabs = (TabHost) 
findViewById(R.id.tabhost);
                        tabs.setup();

                    TabSpec tab = tabs.newTabSpec("TabOne");
                    tab.setContent(R.id.home_scroll);
                    tab.setIndicator("TabOne");
                    tabs.addTab(tab);

//                  tabs.setup();
                    tab = tabs.newTabSpec("TabTwo");
//                  tab.setContent(R.id.home_scroll_events);
                    tab.setContent(new Intent(this, myList.class));
                    tab.setIndicator("TabTwo");
                    tabs.addTab(tab);

                tabs.setCurrentTab(1);

                } catch (Exception e) {
                        // TODO: handle exception
                        Log.e("ERROR0002", e.getMessage());
                }

        }

It triggers the second exception (ERROR0002) when it reach
tabs.setCurrentTab(1)
Commenting out the setContent(Intent) method and use R.id, everything
works fine... minus the list I wanted...
Here is the error:

java.lang.IllegalStateException: Did you forget to call 'public void
setup(LocalActivityManager activityGroup)'?

I already add

                <activity android:name=".myList"
                        android:label="@string/app_name"
                        android:theme="@android:style/Theme.NoTitleBar">
                </activity>

on the android manifest file

Here's the content of myList.java

public class myList extends ListActivity {

        @Override
        public void onCreate(Bundle home_list) {
                super.onCreate(home_list);
                setContentView(R.layout.two);

                String[] items={"lorem", "ipsum", "dolor", "sit", "amet",
                                "consectetuer", "adipiscing", "elit", "morbi", 
"vel",
                                "ligula", "vitae", "arcu", "aliquet", "mollis",
                                "etiam", "vel", "erat", "placerat", "ante",
                                "porttitor", "sodales", "pellentesque", 
"augue"};

                this.setListAdapter(new ArrayAdapter<String>(this,
                                R.layout.row, R.id.label,
                                items));

        }
}

where two.xml is simply like this:

<?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"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Second tab"
    />
</LinearLayout>

and here is row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="44sp"
/>
<TextView
android:id="@+id/information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="life.."
/>
</LinearLayout>

I must have missing something here...can anyone please help?

Thanks.
--
Lawrence Samantha


On Nov 23, 3:52 pm, g1bb <[EMAIL PROTECTED]> wrote:
> Eureka!
>
> I got this to work by taking a look at this sample 
> project:http://www.mail-archive.com/android-developers@googlegroups.com/msg06...
>
> Set my class that extends TabActivity as the main layout.
>
> Thanks again Mark for your help.
>
> On Nov 23, 12:45 pm, g1bb <[EMAIL PROTECTED]> wrote:
>
> > Hi Mark,
>
> > My question now is, now that I have the subclass created, how do I
> > create the tabs using _it_, instead of how I was doing it before via
> > the code in my first post?
>
> > Thanks again for your help.
>
> > On Nov 23, 12:23 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > > g1bb wrote:
> > > > I have no problem with that at all. I found this API demo:
> > > >http://code.google.com/android/samples/ApiDemos/src/com/example/andro...
>
> > > > Which is exactly what I want, but now I'm having a hard time deriving
> > > > from that subclass. Is there an example anywhere of how to do this?
>
> > > I guess I don't understand the question. That API demo shows how to
> > > subclass TabActivity, as do the Tabs1 and Tabs2 demos (same URL, change
> > > the number).
>
> > > What specifically are you having problems with?
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com
>
> > > Android Training on the Ranch! -- Mar 16-20, 
> > > 2009http://www.bignerdranch.com/schedule.shtml

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to