bookwormat / actionbarcompat-with-actionviews Goto Github PK
View Code? Open in Web Editor NEWSimple support for ActionViews in ActionBarCompat
Simple support for ActionViews in ActionBarCompat
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) { /*...*/ } });
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.