1

I'm new at Android Development but I have a good level at iOS/Java Development.

I would like to use something like a Navigation Controller to travel between views (activities, I know) in my Android app. What should I use ?

Thanks for your advices.

Rob
  • 15,732
  • 22
  • 69
  • 107

3 Answers3

2

Check out old class android.app.TabActivity or new one which is called Fragment. At elast TabActivity should be available in most of IDEs.

Here is an example of tab activity:

public class TabbedActivity extends TabActivity {

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

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, TasksActiveListActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost   
        spec = tabHost.newTabSpec("artists").setIndicator("Tasks",
                          res.getDrawable(R.drawable.ic_tab_artists))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, StatisticActivity.class);
        spec = tabHost.newTabSpec("albums").setIndicator("Statistic",
                          res.getDrawable(R.drawable.ic_tab_artists))
                      .setContent(intent);
        tabHost.addTab(spec);  


        intent = new Intent().setClass(this, PurchaseActivity.class);
        spec = tabHost.newTabSpec("albumz").setIndicator("Bonuses",
                          res.getDrawable(R.drawable.ic_tab_artists))
                      .setContent(intent);
        tabHost.addTab(spec);


        tabHost.setCurrentTab(0);
    }



}
Alehar
  • 639
  • 5
  • 16
1

Use fragment instead of old and deprecated TabActivity
please Check out this Post: Android UINavigationController-like feature

Community
  • 1
  • 1
issamux
  • 1,336
  • 1
  • 19
  • 35
0

Intents are used for navigating between views/activities.Check Intent

Aswin
  • 1,154
  • 1
  • 11
  • 29
  • 3
    OP asked about UI element visible to user, not about the programmatic way to open new screen. – Alehar Jul 06 '12 at 13:51