I have a very basic question.
I have a project which has minSDKVersion set to 8 and targetSDK version as 16. Now one of the methods I used setActionView() using this link.
requires a min API level of 11.
I just want to know if it'll work in version 2.2 or not??
Or if there is a way to support previous devices?I want to use collapsible action item which requires the use of 'setActionView()'. Is there any other way to use this?
If it says this feature requires a minimum API level that is greater than what you set in your manifest, you will have trouble using this feature in these older devices. But check Android support library. This may help you support these devices.
if you are using MenuItem com.actionbarsherlock.view.MenuItem.setActionView(View view) then the support for the same should be there in library and will work on 2.2 .
You may also want to check out ActionBarCompat, to give you this functionality... (see this link)
When using android appcompact actionbar library, you could use setActionView with SupportMenuItem.So your code should be like
private SupportMenuItem menuItem=(SupportMenuItem) menu.findItem(R.id.menu_refresh);
menuItem.setActionView(R.layout.progressbar);
You can do it like this with the support library:
MenuItemCompat.setActionView(yourMenuItem, R.layout.your_view);
Related
I'm working with Xamarin.Android.
Appcompat is actually necessary for use material design because the nougat package (Android.support.design) requires it.
But why, for example, if I work only with API 27, I must add the AppCompat package? In my toolBox i've not the floatingActionButton, NavigationDrawer etc.. so I must add this packet to unlock them.
What is exactly this package? I've read on the web that this package works with backward compatibility but I only work with new APIs, so why I must install it?
Thanks.
AppCompat should add the functionality of the latest API to older APIs when needed. For instance, lollipop added the CardView class, which can be used in older Android APIs when AppCompat is used, with some minor differences (some of the Android L animations may not apply on older versions of Android for example). It is recommended to use AppCompat in most cases since more users will be able to run your app when you do (depending on your MinSdkVersion). If you want to know what classes you can access in AppCompat, you can take a look at the features here:
https://developer.android.com/topic/libraries/support-library/features.html
The Xamarin.Android.AppCompat is just what it says. Its a library for App Compatibility for backward compatibility for previous versions of Android and more specifically this version (v7) brings support for Action Bar support. Read more here :
AppCompat
They are libraries used for accessing the latest features of an Android OS version. It is backward compatible by the way.
I'm starting a project with a minimum API level of 21, trying to figure out the right way to implement the ActionBar. The official docs start with using the appcompat library, and the main advantage listed is that it preserves compatibility back to level 7. I don't even want pre-Lollipop installs. Should I use appcompat anyway? Is there any advantage or disadvantage to forgoing the appcompat library?
Is it a good idea to forgo appcompat for a project with minimum API level 21?
Probably not.
First of all, even if you now think you won't, you might still want to downgrade later.
But even if that is not the case, it still provides features. Think of if as being able to upgrade to 24, 25, or 26 in the future without modifying your code.
Appcompat is all about compatibility. The APIs will change less (likely) and you can use interfaces without having to manually check API versions.
I need proof!
Take getColor(int). It was deprecated with version 23. So with 21 you would still use it, with 23 you would (should) have to switch to getColor(int, Theme). ContextCompat of the support library would handle this version check for you.
And this is just one sample.
I am looking for the implementation of floatingaction button for API 19.
I am still using ADT . Is there any library that i can directly use in project.
I saw some libraries in AndroidSTudio but didnt succeed in porting to eclipse.
Here is my original post describing a library with FloatingActionButton implementation.
You may use it even for API level 7! It also supports the elevation feature from API 21.
Do you think is it a good practice to use Android Support Library if my app will support only devices which working on Android 4 ? Or it is unnecessary?
Alex. P.S. Sorry for my English:)
The Android Support package is not only for backports. For example, if you want to use ViewPager, you will need to use the Android Support package. And, in 2014, the Android Support package might get backports of things that are not in whatever your planned android:minSdkVersion is.
If, instead, you are asking whether it is necessary to use FragmentActivity, the AppCompat action bar, and similar backports, no, you will not need those.
Use the support library only if functions you want to use don't work on one of the API levels you target.
I am in the process of making my application compatible with the earlier versions of android using the Android Compatibility library. One of the integral parts of my application is to be able to highlight the user's selection permanently in a list fragment. I was able to do this conveniently using a selector drawable in API level 11 and above using the android:state_activated property. But as it turns out this property was introduced only in API level 11.
Now I plan to achieve the same in earlier API levels, but am out of ideas. Does anyone have any suggestions?
I believe I'll need to create a separate layout for older API versions - res/layout-v10/
Thanks!
Found an excellent solution here: http://udinic.wordpress.com/2011/07/01/selectablelistview-make-selection-work/
View.setSelected(boolean) (since api level 1) made the trick for me