2012-07-06 48 views
1

我是Android開發新手,但在iOS/Java開發方面有很好的水平。有點像Android的導航控制器?

我想使用類似導航控制器的東西在我的Android應用程序中的視圖(活動,我知道)之間旅行。我應該使用什麼?

感謝您的建議。

回答

2

檢出舊類android.app.TabActivity或稱爲Fragment的新類。在彈性TabActivity應該在大多數IDE中可用。

這裏是標籤活動的一個例子:

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); 
    } 



} 
+0

這兩個都可以用Eclipse,我會看看這個。謝謝 ! – Rob 2012-07-06 13:46:03

+1

是的,並檢查我的更新與我的應用程序的源代碼 – Alehar 2012-07-06 13:46:36

0

意圖用於視圖之間進行導航/ activities.Check Intent

+3

OP詢問用戶可見的UI元素,而不是關於打開新屏幕的編程方式。 – Alehar 2012-07-06 13:51:01