i using appcompatactivity actionbar buttons ,in first activity of app.
from second activity using sliding tabs.
my theme.xml(theme 1)
<style name="customactionbartheme" parent="theme.appcompat"> <!-- theme customizations --> <item name="colorprimary">@color/easy</item> <item name="coloraccent">@color/easy</item> <!-- size of action bar--> <item name="actionbarsize">55dp</item> </style> first activity working fine. using above theme
error in sliding tab page
java.lang.runtimeexception: unable start activity componentinfo{com.example.slidingtab}: java.lang.illegalstateexception: activity has action bar supplied window decor. not request window.feature_action_bar , set windowactionbar false in theme use toolbar instead. my theme.xml(theme 2)
<style name="customactionbartheme" parent="theme.appcompat"> </style> <style name="mytheme.noactionbar"> <!-- both of these needed --> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> </style> if using above theme, sliding tab page working fine, first activity showing npe.
problem:
1.i want custom theme first activity,
2.also need sliding tab in second activity
how fix problem please me .
edit :1
added oncreate method
my sliding tab oncreate
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.find_stores_0_tabview__landing); // actionbar button getsupportactionbar().setdisplayhomeasupenabled(true); // initilization // creating toolbar , setting toolbar activity toolbar = (toolbar) findviewbyid(r.id.tool_bar); setsupportactionbar(toolbar); // creating viewpageradapter , passing fragment manager, titles // fot tabs , number of tabs. adapter = new viewpageradapter(getsupportfragmentmanager(), titles,numboftabs); // assigning viewpager view , setting adapter pager = (viewpager) findviewbyid(r.id.pager); pager.setadapter(adapter); // assiging sliding tab layout view tabs = (slidingtablayout) findviewbyid(r.id.tabs); tabs.setdistributeevenly(true); // make tabs fixed set true, // makes tabs space evenly in // available width // setting custom color scroll bar indicator of tab view tabs.setcustomtabcolorizer(new slidingtablayout.tabcolorizer() { @override public int getindicatorcolor(int position) { return getresources().getcolor(r.color.tabsscrollcolor); } }); // setting viewpager slidingtabslayout tabs.setviewpager(pager); // end of oncreate }
i suggest define different theme them.
and think problem wasn't caused sliding tab , check code again.
your first activity theme :
<style name="apptheme" parent="theme.appcompat.light.noactionbar"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> </style> your second activity theme:
<style name="apptheme2" parent="theme.appcompat.light"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> </style> in androidmanifest.xml
<activity android:name=".first activity" android:theme="@style/apptheme"/> <activity android:name=".second activity" android:theme="@style/apptheme2"/>
Comments
Post a Comment