Change ActionBar Background Color Dynamically
android, android-actionbar
Solution
Please try like this
ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ffFEBB31"));
actionBar.setBackgroundDrawable(colorDrawable);
Problem
I would like to know is it possible to change `ActionBar` (in Support Library) Background Color dynamically according to selected page in viewpager or selected actionbar tabs. I have tried with the following code. But, it doesn't work. Please help. ``` mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); if(position == 0){ actionBar.setBackgroundDrawable(new ColorDrawable(Color.GREEN)); }else if(position == 1){ actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLUE)); }else{ actionBar.setBackgroundDrawable(new ColorDrawable(Color.YELLOW)); } } }); ```