Example usage for android.app ActionBar setDisplayHomeAsUpEnabled

List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled

Introduction

In this page you can find the example usage for android.app ActionBar setDisplayHomeAsUpEnabled.

Prototype

public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);

Source Link

Document

Set whether home should be displayed as an "up" affordance.

Usage

From source file:com.xortech.multipanic.PanicAddMain.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sender_tags);

    // REMOVE THE TITLE FROM THE ACTIONBAR
    ActionBar actionbar = getActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);
    actionbar.setDisplayShowTitleEnabled(false);

    panicList = (ListView) findViewById(R.id.tagList);
    panicList.setItemsCanFocus(false);//from w  ww  .j ava  2s. c  o m
    addBtn = (Button) findViewById(R.id.add_btn);

    Set_Referash_Data();

    /**
     * LISTENER TO ADD OR UPDATE A NEW USER TO THE PANIC NUMBERS DATABASE
     * */
    addBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent addPanic = new Intent(PanicAddMain.this, PanicAddUpdate.class);
            addPanic.putExtra("called", "add");
            addPanic.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(addPanic);
            finish();
        }
    });

    /**
     * LISTENER TO OPEN/CLOSE THE EXPANSION OF EACH CLICKED ITEM IN THE LISTVIEW
     */
    panicList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

            View toolbar = view.findViewById(R.id.expandable);

            // Creating the expand animation for the item
            ExpandAnimation expandAni = new ExpandAnimation(toolbar, 500);

            // Start the animation on the toolbar
            toolbar.startAnimation(expandAni);
        }
    });
}

From source file:ca.bitwit.postcard.PostcardAdaptor.java

@JavascriptInterface
public void hideBackButton() {
    activity.runOnUiThread(new Runnable() {
        @Override//  w w w  . java  2  s.  c o m
        public void run() {
            ActionBar actionBar = activity.getActionBar();
            if (actionBar != null) {
                actionBar.setHomeButtonEnabled(false);
                actionBar.setDisplayHomeAsUpEnabled(false);
            }
        }
    });
}

From source file:ca.bitwit.postcard.PostcardAdaptor.java

/**
 * Postcard Specific methods/*  w  w  w  . ja  va 2s. co  m*/
 */

@JavascriptInterface
public void showBackButton() {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ActionBar actionBar = activity.getActionBar();
            if (actionBar != null) {
                actionBar.setHomeButtonEnabled(true);
                actionBar.setDisplayHomeAsUpEnabled(true);
            }
        }
    });
}

From source file:com.tcity.android.ui.overview.project.ProjectOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    myRecreating = false;/*  w  ww.j av  a 2 s.c  o m*/
    myProjectId = calculateProjectId();

    setContentView(R.layout.overview_ui);

    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setTitle(calculateTitle());
        bar.setSubtitle(calculateSubtitle());

        if (!isRootProject(myProjectId)) {
            bar.setDisplayHomeAsUpEnabled(true);
        }
    }

    myLayout = (SwipeRefreshLayout) findViewById(R.id.overview_srlayout);
    myLayout.setColorSchemeResources(R.color.green, R.color.red);
    myLayout.setOnRefreshListener(this);

    myEngine = calculateEngine();
    setListAdapter(myEngine.getAdapter());
}

From source file:com.commonsware.cwac.cam2.support.CameraFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        ab.setBackgroundDrawable(//from   ww  w .ja  v a 2s.c o m
                getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_transparent));
        ab.setTitle("");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ab.setDisplayHomeAsUpEnabled(false);
        } else {
            ab.setDisplayShowHomeEnabled(false);
            ab.setHomeButtonEnabled(false);
        }
    }
}

From source file:cs.man.ac.uk.tavernamobile.WorkflowDetail.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.workflow_detail);

    Activity_Starter_Code = 1;//from   w  w  w. j a  v a2s .  co m

    imageCache = TavernaAndroid.getmMemoryCache();
    mCache = TavernaAndroid.getmTextCache();
    currentActivity = this; // for the access of current activity in
    // OnClickListener

    SlidingMenu slidingMenu = new SlidingMenu(this);
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    slidingMenu.setShadowDrawable(R.drawable.shadow);
    slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    slidingMenu.setFadeDegree(0.35f);
    slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    slidingMenu.setMenu(R.layout.sliding_menu);

    // UI components
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("Workflow Details");
    actionBar.setIcon(this.getResources().getDrawable(R.drawable.taverna_wheel_logo_medium));

    // avatar = (ImageView) findViewById(R.id.avatarImage);
    title = (TextView) findViewById(R.id.workflowTitle);
    TextView version = (TextView) findViewById(R.id.workflowVersion);
    userName = (TextView) findViewById(R.id.uploaderName);
    final Button launch = (Button) findViewById(R.id.workflowlaunchButton);

    // try to get data passed and then load other data e.g. license etc.
    workflow = (Workflow) getIntent().getSerializableExtra("workflow_details");

    // If no data passed in - activity restored etc.
    // get data from memory if the activity was in back stack
    if (workflow == null) {
        workflow = (Workflow) mCache.get("workflow");
        license = (License) mCache.get("license");
        uploader = (User) mCache.get("uploader");
    }
    // if it is not in Cache
    else if (workflow == null) {
        // try to get data from savedInstanceState if the activity
        // was killed due to low memory etc.
        if (savedInstanceState != null) {
            // try to get data from saved instance state
            if (workflow == null) {
                workflow = (Workflow) savedInstanceState.getSerializable("workflow");
            }
            if (license == null) {
                license = (License) savedInstanceState.getSerializable("license");
            }
            if (uploader == null) {
                uploader = (User) savedInstanceState.getSerializable("uploader");
            }
        }
    } else if (workflow == null) {
        // if data can't even be loaded from 
        // saved instance state, inform user 
        // to try start the activity again, 
        // rather than crash the application
        MessageHelper.showMessageDialog(currentActivity, "Oops !",
                "No workflow data found," + "please try again.\n(The message will be dismissed in 4 seconds)",
                null);

        new Handler().postDelayed(new Runnable() {
            public void run() {
                currentActivity.finish();
            }
        }, 4000);
        return;
    }

    /** "workflow" should never be null at this point **/
    title.setText(workflow.getTitle());
    version.setText("Version " + workflow.getVersion());
    // any of the following is null we retrieve data from the server
    if (license == null || uploader == null || avatarBitmap == null) {
        BackgroundTaskHandler handler = new BackgroundTaskHandler();
        handler.StartBackgroundTask(this, this, "Loading workflow data...");
    } else {
        // load avatar image from cache
        avatarBitmap = imageCache.get(uploader.getAvatar().getResource());
    }

    launch.setOnClickListener(new android.view.View.OnClickListener() {

        public void onClick(View v) {
            SystemStatesChecker sysChecker = new SystemStatesChecker(currentActivity);
            if (!(sysChecker.isNetworkConnected())) {
                return;
            }

            WorkflowBE workflowEntity = new WorkflowBE();
            workflowEntity.setTitle(workflow.getTitle());
            workflowEntity.setVersion(workflow.getVersion());
            workflowEntity.setWorkflow_URI(workflow.getContent_uri());
            workflowEntity.setUploaderName(workflow.getUploader().getValue());
            workflowEntity.setAvatar(Bitmap.createScaledBitmap(avatarBitmap, 100, 100, true));

            List<String> privilegesStrings = new ArrayList<String>();
            List<Privilege> privileges = workflow.getPrivileges();
            for (Privilege privilege : privileges) {
                privilegesStrings.add(privilege.getType());
            }
            workflowEntity.setPrivileges(privilegesStrings);

            WorkflowLaunchHelper launchHelper = new WorkflowLaunchHelper(currentActivity,
                    Activity_Starter_Code);
            launchHelper.launch(workflowEntity, 0);
        }
    });

    // Set up fragments
    DetailsPreviewFragment previewFragment = new DetailsPreviewFragment();
    DetailsDescriptionFragment descriptionFragment = new DetailsDescriptionFragment();
    DetailsLicenseFragment licenseFragment = new DetailsLicenseFragment();

    mSectionsPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mSectionsPagerAdapter.addFragment(previewFragment);
    mSectionsPagerAdapter.addFragment(descriptionFragment);
    mSectionsPagerAdapter.addFragment(licenseFragment);

    mViewPager = (ViewPager) findViewById(R.id.workflowDetailsViewPager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.setCurrentItem(0);

    /*myExperimentLoginText = (TextView) findViewById(R.id.wfdMyExperimentLoginState);
    myExperimentLoginText.setOnClickListener(new android.view.View.OnClickListener() {
    @Override
    public void onClick(View v) {
       User user = TavernaAndroid.getMyEUserLoggedin();
       if (user != null) {
          MessageHelper.showOptionsDialog(currentActivity,
                "Do you wish to log out ?", 
                "Attention",
                new CallbackTask() {
                   @Override
                   public Object onTaskInProgress(Object... param) {
                      // Clear user logged-in and cookie
                      TavernaAndroid.setMyEUserLoggedin(null);
                      TavernaAndroid.setMyExperimentSessionCookies(null);
                      refreshLoginState();
                      return null;
                   }
            
                   @Override
                   public Object onTaskComplete(Object... result) {return null;}
                }, null);
       }else{
          Intent gotoMyexperimentLogin = new Intent(
                currentActivity, MyExperimentLogin.class);
          currentActivity.startActivity(gotoMyexperimentLogin);
       }
    }
       });*/

    this.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}

From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mission_planner);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    getActionBar().setTitle(R.string.title_activity_mission_planner);

    if (savedInstanceState == null) {
        // Load saved missionData if available.
        try {//ww w  . jav a 2s .co  m
            FileInputStream inStream = new FileInputStream(
                    Environment.getExternalStorageDirectory() + File.separator + "MissionData");
            ObjectInputStream objectInStream = new ObjectInputStream(inStream);
            int count = objectInStream.readInt();
            for (int i = 0; i < count; i++)
                missionData.add((MissionData) objectInStream.readObject());
            objectInStream.close();
        } catch (OptionalDataException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // if the list is empty, add the default planet
        if (missionData.size() == 0) {
            missionData = setFirstMissionData();
        }
    } else {
        missionData = savedInstanceState.getParcelableArrayList("key");
    }

    mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground);
    mListView = (ListView) findViewById(R.id.list);
    tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV);
    mAdapter = new StableArrayAdapter(this, missionData, mTouchListener);

    // add the newDestination button as a footer below the listview
    ImageView newDestination = new ImageView(this);
    newDestination.setImageResource(R.drawable.ic_plus);
    mListView.addFooterView(newDestination);
    newDestination.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use
            if (missionData.size() < 1) {
                possibleIconState = 1;
            }
            Intent intent = new Intent(MissionPlanner.this, MissionDestination.class);
            intent.putExtra("possibleIconState", possibleIconState);
            intent.putExtra("isNewItem", true); // Places the result as a new item in the listview
            startActivityForResult(intent, 0);
        }
    });
    mListView.setAdapter(mAdapter);
}

From source file:com.lugia.timetable.SubjectDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_subject_detail);

    mWeekName = Utils.getWeekNameString(SubjectDetailActivity.this, Utils.SHORT_WEEK_NAME);
    mTimeName = Utils.getTimeNameString(SubjectDetailActivity.this);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    PagerTabStrip tabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip);

    RelativeLayout headerLayout = (RelativeLayout) findViewById(R.id.layout_header);

    TextView subjectTitleTextView = (TextView) findViewById(R.id.text_subject_title);
    TextView lectureSectionTextView = (TextView) findViewById(R.id.text_lecture_section);
    TextView tutorialSectionTextView = (TextView) findViewById(R.id.text_tutorial_section);
    TextView creditHoursTextView = (TextView) findViewById(R.id.text_credit_hour);

    Bundle intentExtra = getIntent().getExtras();

    SubjectList subjectList = SubjectList.getInstance(SubjectDetailActivity.this);

    String subjectCode = intentExtra.getString(EXTRA_SUBJECT_CODE);

    mSubject = subjectList.findSubject(subjectCode);

    String subjectDescription = mSubject.getSubjectDescription();
    String lectureSection = mSubject.getLectureSection();
    String tutorialSection = mSubject.getTutorialSection();

    int colorIndex = mSubject.getColor();
    int creditHours = mSubject.getCreditHours();

    mColors = Utils.getForegroundColor(SubjectDetailActivity.this, colorIndex);
    mBackgrounds = Utils.getBackgroundDrawableResourceId(colorIndex);

    viewPager.setAdapter(adapter);/*  w w w  . jav  a 2s  .co  m*/
    headerLayout.setBackgroundColor(mColors);

    tabStrip.setTextColor(mColors);
    tabStrip.setTabIndicatorColor(mColors);

    subjectTitleTextView.setText(subjectCode + " - " + subjectDescription);
    lectureSectionTextView.setText(lectureSection);
    tutorialSectionTextView.setText(tutorialSection);
    creditHoursTextView.setText(creditHours + " Credit Hours");

    if (tutorialSection == null)
        tutorialSectionTextView.setVisibility(View.GONE);

    // user click the event reminder notification, show the event detail
    if (getIntent().getAction() != null && getIntent().getAction().equals(ACTION_VIEW_EVENT)) {
        long eventId = intentExtra.getLong(EXTRA_EVENT_ID, -1);

        Event event = mSubject.findEvent(eventId);

        if (event != null) {
            Bundle args = new Bundle();

            args.putString(EventDetailDialogFragment.EXTRA_SUBJECT_CODE, mSubject.getSubjectCode());
            args.putLong(EventDetailDialogFragment.EXTRA_EVENT_ID, event.getId());

            // dont allow event editing in such situation
            args.putBoolean(EventDetailDialogFragment.EXTRA_EDITABLE, false);

            EventDetailDialogFragment f = EventDetailDialogFragment.newInstance(args);

            f.show(getFragmentManager(), event.getName());
        } else
            Toast.makeText(SubjectDetailActivity.this, "No such event.", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.cachirulop.moneybox.activity.MainActivity.java

/**
 * Initialize the application action bar
 *///from   w  ww.j  a  v a 2 s .c o m
private void createActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
}

From source file:com.seekon.yougouhui.activity.shop.RegisterShopActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.shop_register);
    mInflater = LayoutInflater.from(this);

    ActionBar actionBar = this.getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    initViews();//from   w  ww  . j av  a2 s  .c om

    mLocationClient = new LocationClient(getApplicationContext()); // LocationClient
    mLocationClient.registerLocationListener(new MyLocationListener());
    mLocationClient.setLocOption(LocationUtils.getDefaultLocationOption());

}