Help with the tab tutorial

Hey I am new to android development and most programing in general other then 2 semesters of C++. But my question revolves around this tutorial http://developer.android.com/resources/tutorials/views/hello-tabwidget.html I was able to follow how to write the previous ones but when it comes to this one I am having trouble. My question is, what does it mean when it says to create a separate activity for each tab and how do I go about that?

Answers


You simply need to create two or more activities via the normal means: create a class that extends Activity, declare them in the manifest, ect. Then create your tab activity that extends the TabActivity. From there this code snip highlights the high points (note that I assume two activities exist called ActivityA and ActivityB)...

public class MyTabActivity extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_tab_layout);

        final Resources res     = getResources(); 
        final TabHost   tabHost = getTabHost();  

        TabHost.TabSpec spec;  
        Intent          intent;  

        /* Add tab A */
        intent = new Intent().setClass(this, ActivityA.class);
        spec   = tabHost.newTabSpec("tab_a")
                        .setIndicator("Tab A", res.getDrawable(R.drawable.ic_tab_a))
                        .setContent(intent);
        tabHost.addTab(spec);

        /* Add tab B */
        intent = new Intent().setClass(this, ActivityB.class);
        spec   = tabHost.newTabSpec("tab_b")
                        .setIndicator("Tab B", res.getDrawable(R.drawable.ic_tab_b))
                        .setContent(intent);
        tabHost.addTab(spec);
    }
}

Need Your Help

Why is RSAParameters Modulus not equal product of P and Q?

c# .net cryptography rsa

The values of P and Q do not match value of the Modulus of the .Net RSAParameters.

Adding column with default value to large table

sql sql-server performance

I have a table with 40mil records. I need to add a new INT NOT NULL column to that table, with default value = 0

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.