Error starting Android tutorial HelloTabWidget under SDK 1.5: "setCurrentTag (getIntent ())"

not compiled. Indeed: even in 1.5 this api, getIntent () is already listed as deprecated.

The error message I get complains that getIntent () does not return a String, but setCurrentTab () expects a string.

If I guess and change the line as follows:

"tabHost.setCurrentTab (1); // has been installedCurrentTab (getIntent ())",

then it compiles, builds, but does not start. I get the error "stopped unexpectedly" from the emulator. I can’t even get Log.d for output, so it seems to “unexpectedly” end unexpectedly.

So, the first and main question: what is the correct fix for "tabHost.setCurrentTab (getIntent ())" in the last line of OnCreate () in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html ?

The second and simpler question is: did I correctly replace "mTabHost" with tabHost in one place where this happens?

+3
source share
2 answers

Here are the problems and corrections for this particular tutorial:

Step 2: When creating your actions, if you do not create them through the manifest, you will need to add them to the manifest manually.

Add these lines to AndroidManifest.xml:

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

3: ic_tab_artists.xml. ic_tab_songs.xml ic_tab_albums.xml. ic_tab_artists.xml( HelloTabView.java, artist.xml ).

4: /res/layout/main (a, :)

      android:padding="5dp" />
    </LinearLayout>
</TabHost>

6: , mTabHost tabHost. .

, getIntent() . id. :

 tabHost.setCurrentTabByTag("albums");
+4

Android Meetup , : , , , - "tabHost.setCurrentTab(0);// CurrentTab (getIntent())".

, , HelloTabWidget: | | SongsActivity , manifest.xml. , .

0

Source: https://habr.com/ru/post/1730939/


All Articles