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. SMS Header

I've been looking around and have been wondering is there any way to
modify the SMS header before sending it out?

-- 

2. Which UI approach is better?

I'm navigating through a 3-level hierarchy of names to get to a
document view page. I've set up tabs for the 3 levels. The tabs are
left, middle, and right where the right tab is the lowest level of the
hierarchy. Each tab has a list of 10 to 20 RadioButtons with the
names. This all works great and is very efficient and intuitive.

One note is that there may be 1000 documents available (from an online
source) but the average user will only be viewing a handful regularly.
So I store the choices for each of the 3 tabs. This way a user can
quickly navigate to his favorite without having to negotiate the
entire hierarchy each time.

My question comes when the user is on the right tab. At this point
they have navigated through to the document they want and I'm
wondering what is the best way to initiate the document view page.
Remember that most of the navigation happens on the right tab in the
small set of documents the user regularly visits, with only occasional
visits to the other tabs. So making the right tab efficient is good.

My current approach is to add a LongClickListener to the buttons of
the right tab. Then a press-and-hold kicks off the document view. This
certainly minimizes the number of objects on the screen and the number
of separate clicks required to get to the document but I question
whether new users will know that a long press is expected. I guess I
could put up some Toast if the user doesn't do anything for 5 seconds
but that still seems clunky.

Another approach is to add a Button at the top of the right tab
RadioButtons. This has the merit of being dead obvious but it's a less
efficient use of screen space and also an extra click for an
experienced user.

What do you all think? Maybe a third way?

-- 

3. BroadcastReceiver not working for Car Dock

4. strange LVL calback errors

5. wpa_cli not found

6. Open Max Test App documents

7. Buffering problem while reading an h264 video (using HTTP protocol)