title: How to change tab background color programmatically?
body: <p>I am trying to change the background color of selected (active tab). My case is by default all tabs are white when user select the tab it gets the color I want.
  I am using a library name  <strong>PagerSlidingTabStrip</strong> ... what I tried so far is:</p>
  
  <p>On tab change I call this code. It works very fine and change the text color. Now all I want to change the same tab background color. </p>
  
  <pre><code>private void setSelectedTabColor(int position) {
      for(int i=0; i&lt;tabStrip.getChildCount(); i++)  
      {  
          LinearLayout view = (LinearLayout) tabStrip.getChildAt(0);
          TextView textView = (TextView) view.getChildAt(i);
          textView.setTextColor(getResources().getColor(R.color.black)); 
      }  
  
      LinearLayout view = (LinearLayout) tabStrip.getChildAt(0);
      TextView textView = (TextView) view.getChildAt(position);
      textView.setTextColor(getResources().getColor(R.color.white));
  }
  </code></pre>
  
  <p>By trying the below code in loop, I get null pointer exception.</p>
  
  <pre><code>tabStrip.getChildAt(i).setBackgroundColor(getResources().getColor(R.color.dash_bar));
  </code></pre>