簡體   English   中英

像Android的導航控制器?

[英]Something like a Navigation Controller for Android?

我是Android開發人員的新手,但我在iOS / Java開發方面有很好的水平。

我想在我的Android應用程序中使用類似導航控制器之類的東西來瀏覽視圖(活動,我知道)。 我該怎么用?

謝謝你的建議。

查看舊類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);
    }



}

使用片段而不是舊的和不推薦使用的TabActivity
請查看此帖子: Android UINavigationController之類的功能

意圖用於在視圖/活動之間導航。檢查意圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM