Tabs by Intent

by r45k » Sat, 14 Mar 2009 02:11:45 GMT


Sponsored Links
 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>

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. background drawable

I have created a background drawable for my widget.
How can I specify the size of the background drawable so that it won't
stretch of my widget?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+android:id/background"
android:drawable="@drawable/bkgd" />
</layer-list>

bkgd.png is a png file.

Thank you.

--~--~---------~--~----~------------~-------~--~----~

2. define public or private resources

just for test
i add some drawable resources to the /framework/base/core/res/res
and   >make
i can find it in the com.android.internal.R file, but i want to see it
in the android.R file
how to define the resources  a public or a private resource ?
--~--~---------~--~----~------------~-------~--~----~

3. Services and proximity alerts

4. How to remove or hide an app

5. Problems with background activities or partial locks or something completely altogether?!

6. Problems with background activities or partial locks or something completely altogether?!

7. nested scopes