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. APK not visible in market for HTC Tattoo Android Phone ?

The tattoo has a low density screen if I remember correctly. Your application 
would have to support low density screens explicitly for it to show up in the 
market.

Regards
S





> 

2. The method versionName() is undefined for the type PackageInfo

A few thoughts, and them my code that's producing the above error (and
I'm perplexed as to why).

1.)  I'm using API 6
2.)  I have "import android.content.pm.PackageInfo;" and "import
android.content.pm.PackageManager;" at the top of the java class.
3.)  I've hit "control-shift-o" in eclipse to try to get it to import
anything that might be missing.
4.)  Eclipse shows the methods avaiable on PackageInfo (and it lists
versionName as one of them) but then gives the error message "The
method versionName() is undefined for the type PackageInfo".

My question, what am I doing wrong (I've tried other variations of the
getPackageManager line where I specified META_DATA, etc.)

// Begin Code
String version = " (Development)";

try {
  PackageInfo pi = getPackageManager().getPackageInfo
("com.testdoman.testapplication", 0);
  version = pi.versionName();     // this is the line Eclipse complains
about
}
catch (PackageManager.NameNotFoundException e) {
        // eat error, for testing
}

--

3. NexusOne newbie and disappointed... here is why...

4. NexusOne newbie and disappointed... here is why...

5. AccountManager sync policy

6. Finally Hit a Wall

7. installing application silently in android