android - How to replace Sherlock ActionBar in with AppCompat -
i have old project in eclipse uses sherlock actionbar, replace actionbar apptheme or appcompat actionbar. want actionbar have same features such as, dropdown list view. please help.
public class mainactivity extends sherlockactivity implements actionbar.onnavigationlistener, onitemclicklistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); context context = getsupportactionbar().getthemedcontext(); r.layout.sherlock_spinner_item); list.setdropdownviewresource(r.layout.sherlock_spinner_dropdown_item); getsupportactionbar().setnavigationmode(actionbar.navigation_mode_list); getsupportactionbar().setlistnavigationcallbacks(list, this);
use toolbar support design library , appcompatactivity
public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { toolbar toolbar = findviewbyid(r.id.toolbar) setsupportactionbar(toolbar); } }
and add <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary"/>
in r.layout.activity_main
Comments
Post a Comment