I can't seem to run the code below without crashing. I followed the
tuts online about tabs exactly and got it working until i changed one
line of code to set a tab's content to a separate class. NOTE: it ran
fine before i added the line that made the content a new class...


public class HelloTabWidget extends TabActivity {
    @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

        final TabHost mTabHost = getTabHost();
          mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
                             .setIndicator("PROFILE").setContent(new
Intent(this, Profile.class)));
                mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
                             .setIndicator("FRIENDS").setContent
(R.id.textview2));
              mTabHost.addTab(mTabHost.newTabSpec("tab_test3")
                              .setIndicator("STATS").setContent
(R.id.textview3));

         mTabHost.setCurrentTab(0);
     }



}






I don't really quite understand whats going wrong when this is
basically code for code from the API demo...
I'm also assuming my error has to do with this line of code:

....setContent(new Intent(this, Profile.class)));.....





here is the profile class:


public class Profile extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Use a custom layout file
        setContentView(R.layout.main2);
    }
}






and it's main2 xml:




XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android";
android:id="@+id/screen"
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="fill_parent"
android:layout_height="fill_parent"
        android:orientation="vertical">
     <TextView
           android:layout_width="fill_parent"
     android:layout_height="wrap_content"
          android:text="@string/welcome"/>
    </LinearLayout>
</ScrollView>

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

Reply via email to