Example usage for android.app ActionBar setIcon

List of usage examples for android.app ActionBar setIcon

Introduction

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

Prototype

public abstract void setIcon(Drawable icon);

Source Link

Document

Set the icon to display in the 'home' section of the action bar.

Usage

From source file:de.zell.android.util.activities.MainNavigationActivity.java

private void initActionBar() {
    ActionBar bar = getActionBar();
    // enable ActionBar app icon to behave as action to toggle nav drawer
    bar.setIcon(getActionBarIcon());
    bar.setDisplayHomeAsUpEnabled(true);
    bar.setHomeButtonEnabled(true);/*from w w  w  .j  ava 2  s  . co  m*/
}

From source file:com.cypress.cysmart.BLEServiceFragments.CapsenseService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*from   www  . ja  v a  2 s  . co  m*/
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(false);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

@Override
protected void setActionBarIcon(final Drawable icon) {
    final ActionBar actionBar = getActionBar();
    if (actionBar == null) {
        throw new RuntimeException("ActionBar should not be null");
    }//from  w w w. jav  a 2  s. c  om
    actionBar.setIcon(icon);
}

From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.add_to_music_library, menu);

    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
    actionBar.setIcon(
            mContext.getResources().getIdentifier(libraryIconName, "drawable", mContext.getPackageName()));
    SpannableString s = new SpannableString(libraryName);
    s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    actionBar.setTitle(s);/*  w  ww. j a  va2s . c  o m*/

    return super.onCreateOptionsMenu(menu);
}

From source file:activities.PaintingActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setLogo(R.drawable.navbar_logo);
    actionBar.setIcon(R.drawable.ic_drawer);
}

From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();//w w w .  ja  v  a2  s.co m
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(true);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

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

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

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

        ab.setBackgroundDrawable(//from w  ww  . j av a2 s . co m
                getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_translucent));
        ab.setTitle("");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setHomeAsUpIndicator(R.drawable.cwac_cam2_ic_close_white);
        } else {
            ab.setIcon(R.drawable.cwac_cam2_ic_close_white);
            ab.setDisplayShowHomeEnabled(true);
            ab.setHomeButtonEnabled(true);
        }
    }
}

From source file:za.ac.uct.cs.lwsjam005.eshelf.activities.ReadActivity.java

private void setupActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setSplitBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));

    actionBar.setIcon(thisBook.getIcon());
    actionBar.setTitle(thisBook.getTitle());
    actionBar.setSubtitle(thisBook.getAuthor());

}

From source file:com.example.gangzhang.myapplication.VideoPlayerActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(getTitle());/* w ww. j  a va  2  s.  c o  m*/
    actionBar.setIcon(null);
    actionBar.setDisplayUseLogoEnabled(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 ww. j  a  v  a 2 s. 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);
}