org.deviceconnect.android.deviceplugin.hue.activity.HueMainActivity.java Source code

Java tutorial

Introduction

Here is the source code for org.deviceconnect.android.deviceplugin.hue.activity.HueMainActivity.java

Source

/*
HueMainActivity
Copyright (c) 2014 NTT DOCOMO,INC.
Released under the MIT license
http://opensource.org/licenses/mit-license.php
*/

package org.deviceconnect.android.deviceplugin.hue.activity;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;

import org.deviceconnect.android.deviceplugin.hue.R;
import org.deviceconnect.android.deviceplugin.hue.activity.fragment.HueFragment01;

/**
 * Hue???.
 *
 * @author NTT DOCOMO, INC.
 */
public class HueMainActivity extends FragmentActivity {

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
        getActionBar().setTitle(R.string.activity_setting_page_title);

        // FragmentManager?.
        FragmentManager manager = getSupportFragmentManager();

        // FirstFragment??.
        HueFragment01 mFirstFragment = new HueFragment01();

        // FragmentTransaction?.
        FragmentTransaction transaction = manager.beginTransaction();

        // Fragment?.
        transaction.add(R.id.fragment_frame, mFirstFragment, "fragment002");
        transaction.commit();
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
}