Giter VIP home page Giter VIP logo

actionbarcompat-with-actionviews's Introduction

This is not a complete project, but a modified version of a class that
is part of ActionBarCompat:
http://developer.android.com/resources/samples/ActionBarCompat/index.html. You
need to get the source from this url and override
ActionBarHelperBase.java with the file in this repository to make this
work.

=================================================================

ActionBar is a UI pattern that has found its way into the Android SDK
in version 3.0 . If you want to support devices running Versions lower
than 3.0, you need some code that falls back to an alternative
implementation of the actionbar for devices running up to Android 2.3,
and uses the existing one in 3.0 and above.

There are various projects that do this. http://actionbarsherlock.com/
is a fully functional implementation that is, as far as I know, fully
compatible with the 3.0 APIs. The only downside to actionbarsherlock
is that the project is an extension to Google's Android Compability
Library, which means you have to use Actionbarsherlock instead of the
ACL. It's another dependency.

Google recommends a simpler, but also more restrictive solution: They
offer a piece of sample code that they recommend you use in your
project. They call it ActionBarCompat: http://developer.android.com/resources/samples/ActionBarCompat/index.html

One of the things that ActionBarCompat does not support is Adding an
ActionView to the Actionbar in a phone device.

I need such an ActionView in my project, but other that that,
ActionBarCompat works fine. Fortunately , the code from Google is not
very complicated, and it is quite easy to add support for this.

Just replace ActionBarHelperBase.java with my edited version. Then, if
you provide the android:actionLayout attribute to your menu
definition, the view in your layout will be added to the ActionBar
instead of the icon.



One thing that I did not implement is MenuItem#getActionView(). This
is the method that allows you to retrieve the ActionView from code.

So if you want, for example, add a listener to your view in code, you
have to search for it using Activity.findById(), after the actionBar
has been created.


e.g.


View myCustomView = this.findViewById(R.id.mycustomview);
myCustomView.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    /*...*/
  }
});

actionbarcompat-with-actionviews's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

khalidelsayed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.