android - Is it necessary to perform API if-else check when using AppCompat -


previously, i'm using sherlockactionbar library. following code work, across android 2.3 till android 5.

this.searchmenuitem.collapseactionview(); 

however, after migrating appcompat, need migrate following code

menuitemcompat.collapseactionview(jstockfragmentactivity.this.searchmenuitem); 

when @ documentation http://developer.android.com/guide/topics/ui/actionbar.html#actionview, states that

on api level 11 or higher

get action view calling getactionview() on corresponding menuitem:

menu.finditem(r.id.action_search).getactionview() 

i wondering, necessary need write migrated code in following way?

if (android.os.build.version.sdk_int >= android.os.build.version_codes.ice_cream_sandwich) {     this.searchmenuitem.collapseactionview(); } else {     menuitemcompat.collapseactionview(this.searchmenuitem); } 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -