トラッキング コード

1/18/2012

Using the App Icon for Navigation

What is the App Icon for Navigation?

You can see the App Icon for Navigation in Market App.



How to use the App Icon for Navigation

To enable the icon for up navigation, call setDisplayHomeAsUpEnabled(true) on your ActionBar.

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

When the user touches the icon, Android framework is called onOptionsItemSelected() method with the android.R.id.home ID in Activity Class.

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
        case android.R.id.home:
            // app icon in action bar clicked;
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }

No comments:

Post a Comment