title: how to change textcolor of selected list item both header and child in expandable listview?
body: <p>what i need:<a href="https://i.stack.imgur.com/3zJLh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3zJLh.png" alt="enter image description here"></a>
  the above screen is my drawer.In that expandable listview,if i pressed the "DashBoard" header list i will redirect to dashboard activity.Here,i need "Dashboard" text to be blue color and other text to be black.when i click "Today followups" childview i want "CRM" and "Today followups" text to blue color and others to be black color.
  my Navigation drawer activity:</p>
  
  <pre><code>    public class BaseActivity extends AppCompatActivity {
  
      protected DrawerLayout drawer;
      ExpandableListView expListView;
      ExpandableListAdapter listAdapter;
      HashMap&lt;String, List&lt;String&gt;&gt; listDataChild,listDatachild2;
      List&lt;String&gt; listDataHeader;
      List&lt;String&gt; listDataHeader2;
      public List&lt;Integer&gt; groupImages;
      private NavigationView navigationView;
      ViewStub viewStub;
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_testingnavi);
  
      }
  
      public void preparedrawer(){
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          navigationView = (NavigationView)findViewById(R.id.nav_view);
          expListView = (ExpandableListView)findViewById(R.id.navList);
           drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          drawer.setDrawerListener(toggle);
          toggle.syncState();
  
  
          setprofileimage();
          prepareListData();
  
          listAdapter = new ExpandableListAdapter(
                  this, listDataHeader,groupImages,listDataChild,drawer);
          expListView.setAdapter(listAdapter);
  
          expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
              @Override
              public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
                  return false;
              }
          });
  
          expListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  
              @Override
              public void onGroupExpand(int groupPosition) {
  
  
  
                  //  mDrawerLayout.closeDrawers();
                  Toast.makeText(getApplicationContext(),
                          listDataHeader.get(groupPosition) + " Expanded",
                          Toast.LENGTH_SHORT).show();
              }
          });
  
          expListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  
              @Override
              public void onGroupCollapse(int groupPosition) {
  
                  Toast.makeText(getApplicationContext(),
                          listDataHeader.get(groupPosition) + " Collapsed",
                          Toast.LENGTH_SHORT).show();
  
              }
          });
  
          expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
              View _lastColored;
  
              @Override
              public boolean onChildClick(ExpandableListView parent, View v,
                                          int groupPosition, int childPosition, long id) {
                  drawer.closeDrawer(GravityCompat.START);
                  // TODO Auto-generated method stub
  
  
  
                  Toast.makeText(
                          getApplicationContext(),
                          listDataHeader.get(groupPosition)
                                  + " : "
                                  + listDataChild.get(
                                  listDataHeader.get(groupPosition)).get(
                                  childPosition), Toast.LENGTH_SHORT)
                          .show();
  
  
                  return false;
              }
          });
      }
      public void setviewstub(int layout_id){
          viewStub=(ViewStub)findViewById(R.id.view_stub);
          viewStub.setLayoutResource(layout_id);
          viewStub.inflate();
  
  
      }
      public void setprofileimage(){
  
          CircleImageView profilePictureView = (CircleImageView) navigationView.getHeaderView(0).findViewById(R.id.profile_image);
          TextView Usernamenav=(TextView)navigationView.getHeaderView(0).findViewById(R.id.Usernamenav);
  
          final Userloginsession userloginsession = new Userloginsession(getApplicationContext());
          final HashMap&lt;String, String&gt; userlist = userloginsession. isGetuserDetails();
          String first_namee=userlist.get(Userloginsession.IS_FIRST_NAME);
          String last_namee=userlist.get(Userloginsession.IS_LAST_NAME);
          Picasso.with(BaseActivity.this)
                  .load(Url.imgurl + userlist.get(Userloginsession.IS_IMAGE))
                  .fit().centerCrop()
                  .into(profilePictureView);
          Usernamenav.setText(first_namee+" "+last_namee);
          Log.i("imgurl",Url.imgurl + userlist.get(Userloginsession.IS_IMAGE));
  
  
      }
      private void prepareListData() {
  
          groupImages= new ArrayList&lt;Integer&gt;();
          groupImages.add(R.drawable.dashboard_icon);
          groupImages.add(R.drawable.crm_icon);
          groupImages.add(R.drawable.accouns_icon);
          groupImages.add(R.drawable.settings_icon);
          groupImages.add(R.drawable.logout_icon);
  
  
  
          listDataHeader = new ArrayList&lt;String&gt;();
          listDataChild = new HashMap&lt;String, List&lt;String&gt;&gt;();
  
          // Adding child data
          listDataHeader.add("Dashboard");
          listDataHeader.add("CRM");
          listDataHeader.add("Accounts");
          listDataHeader.add("Settings");
          listDataHeader.add("LogOut");
  
          // Adding child data
  
          List&lt;String&gt; Dashboard = new ArrayList&lt;String&gt;();
  
          List&lt;String&gt; CRM = new ArrayList&lt;String&gt;();
          CRM.add("Today Followup's");
          CRM.add("Unhandled Followup(s)");
          CRM.add("Today Appointments");
          CRM.add("Unhandled Appointment(s)");
          CRM.add("Cold Call(s)");
  
  
          List&lt;String&gt; Accounts = new ArrayList&lt;String&gt;();
          Accounts.add("Quotations");
          Accounts.add("Orders");
          Accounts.add("Payments");
  
  
          List&lt;String&gt; Settings = new ArrayList&lt;String&gt;();
  
          List&lt;String&gt; Logout = new ArrayList&lt;String&gt;();
          listDataChild.put(listDataHeader.get(0), Dashboard);
          listDataChild.put(listDataHeader.get(1), CRM); // Header, Child data
          listDataChild.put(listDataHeader.get(2), Accounts);
          listDataChild.put(listDataHeader.get(3), Settings);
          listDataChild.put(listDataHeader.get(4), Logout);
  
      }
  public static void dointent(Context A1, Class A2){
  
      Intent i = new Intent().setClass(A1, A2);
      i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
      A1.startActivity(i);
  
  
  }
      public  static Typeface settypefacess(Context _context,String fonts){
  
          Typeface roboto = Typeface.createFromAsset(_context.getAssets(),
                  fonts);
          return roboto;
      }
  
  }
  </code></pre>
  
  <p>My adapter:`</p>
  
  <pre><code>public class ExpandableListAdapter extends BaseExpandableListAdapter {
      private Context _context;
      private List&lt;String&gt; _listDataHeader; // header titles
      // child data in format of header title, child title
      private List&lt;Integer&gt; _group;
  
      private DrawerLayout _drawer;
  
      private static final int[] EMPTY_STATE_SET = {};
      private static final int[] GROUP_EXPANDED_STATE_SET =
              {android.R.attr.state_expanded};
      private static final int[][] GROUP_STATE_SETS = {
              EMPTY_STATE_SET, // 0
              GROUP_EXPANDED_STATE_SET // 1
      };
  
      private HashMap&lt;String, List&lt;String&gt;&gt; _listDataChild;
      ExpandableListView expandList;
      public ExpandableListAdapter(Context context, List&lt;String&gt; listDataHeader, List&lt;Integer&gt; group,
                                   HashMap&lt;String, List&lt;String&gt;&gt; listChildData, DrawerLayout drawer) {
          this._context = context;
          this._listDataHeader = listDataHeader;
          this._listDataChild = listChildData;
          this._group=group;
          this._drawer=drawer;
  
      }
  
      @Override
      public Object getChild(int groupPosition, int childPosititon) {
          return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                  .get(childPosititon);
      }
      @Override
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
      @Override
      public View getChildView(final int groupPosition, final int childPosition,
                               boolean isLastChild, View convertView, ViewGroup parent) {
  
          final String childText = (String) getChild(groupPosition, childPosition);
          int childpositionaa= (int) getChildId(groupPosition,childPosition);
          int gropuposi= (int) getGroupId(groupPosition);
          Log.i("groupposi", String.valueOf(+groupPosition));
          Log.i("groupposicc", String.valueOf(+childPosition));
          Log.i("groupposiccee", String.valueOf(+childpositionaa));
          int child3position=(int)getChildId(1,childPosition);
          Log.i("groupposiccee33", String.valueOf(+child3position));
  
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this._context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.list_item, null);
          }
  Log.i("childposition",""+childPosition);
          Typeface roboto = Typeface.createFromAsset(_context.getAssets(),
                  "font/Roboto-Light.ttf");
          AppCompatTextView txtListChild = (AppCompatTextView) convertView
                  .findViewById(R.id.lblListItem);
          txtListChild.setOnTouchListener(new View.OnTouchListener() {
              @Override
              public boolean onTouch(View view, MotionEvent motionEvent) {
                  switch (motionEvent.getAction()) {
                      case MotionEvent.ACTION_DOWN:
  
                          _drawer.closeDrawer(GravityCompat.START);
                          switch (groupPosition) {
                              case 0:
                                  break;
                              case 1:
                                  switch (childPosition){
                                      case 0:
                                          BaseActivity.dointent(_context.getApplicationContext(),Handled_follow.class);
  
                                          break;
                                      case 1:
                                          BaseActivity.dointent(_context.getApplicationContext(), Unhanded_follow.class);
                                          break;
                                      case 2:
                                          BaseActivity.dointent(_context.getApplicationContext(), Navi_recyview.class);
                                                  break;
                                      case 3:
                                          BaseActivity.dointent(_context.getApplicationContext(), Unhandled_appoint.class);
                                                                            break;
                                      case 4:
                                          BaseActivity.dointent(_context.getApplicationContext(), Cold_calls.class);
                                                                                break;
                                  }
                                  break;
                          }                        
                          break;
                  }
  
                  return false;
              }
          });
          AppCompatTextView txtchildcount= (AppCompatTextView) convertView
                  .findViewById(R.id.lblistnavcount);
          txtListChild.setText(childText);
          txtListChild.setTypeface(roboto);
  
  
          txtchildcount.setText(myList.get(childpositionaa));
          if(gropuposi==2){
              if(childpositionaa==0){
                  txtchildcount.setText(myList.get(5));
  
              }
              else{
                  txtchildcount.setText(myList.get(4));
              }
              txtchildcount.setText(myList.get(childpositionaa+5));
          }
          else{
              txtchildcount.setText(myList.get(childpositionaa));
          }
          return convertView;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                  .size();
      }
  
      @Override
      public Object getGroup(int groupPosition) {
          return this._listDataHeader.get(groupPosition);
      }
  
      @Override
      public int getGroupCount() {
          return this._listDataHeader.size();
      }
  
      @Override
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      @Override
      public View getGroupView(final int groupPosition, boolean isExpanded,
                               View convertView, ViewGroup parent) {
          String headerTitle = (String) getGroup(groupPosition);
          int headerimg = _group.get(groupPosition);
          Log.i("groupposigroupview", String.valueOf(+groupPosition));
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this._context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.list_group, null);
          }
          AppCompatTextView lblListHeader = (AppCompatTextView) convertView
                  .findViewById(R.id.lblListHeader);
          View ind = convertView.findViewById( R.id.indicicon);
  
          if( ind != null ) {
              ImageView indicator = (ImageView)ind;
              if( getChildrenCount( groupPosition ) == 0 ) {
                  indicator.setVisibility( View.INVISIBLE );
              } else {
                  indicator.setVisibility(View.VISIBLE);
                  if (isExpanded) {
                      lblListHeader.setTextColor(_context.getResources().getColor(R.color.colorPrimary));
                      indicator.setImageResource(R.drawable.ic_expand_less_black_18dp);
                  } else {
                      lblListHeader.setTextColor(_context.getResources().getColor(R.color.colorlisthead));
  
                      indicator.setImageResource(R.drawable.ic_expand_more_black_18dp);
                  }
              }
          }
          Typeface roboto = Typeface.createFromAsset(_context.getAssets(),
                  "font/Roboto-Regular.ttf"); //use this.getAssets if you are calling from an Activity
  
  
          lblListHeader.setTypeface(roboto);
          lblListHeader.setText(headerTitle);
          ImageView imgsListHeader = (ImageView) convertView
                  .findViewById(R.id.imagview);
  
          imgsListHeader.setImageResource(headerimg);
  lblListHeader.setOnTouchListener(new View.OnTouchListener() {
      @Override
      public boolean onTouch(View view, MotionEvent motionEvent) {
          switch (motionEvent.getAction()) {
              case MotionEvent.ACTION_DOWN:
  
                  switch (groupPosition) {
                      case 0:
                          _drawer.closeDrawer(GravityCompat.START);
                          BaseActivity.dointent(_context.getApplicationContext(),Dashboard.class);
                          break;
                      case 1:
  
                          break;
                      case 2:
  
                      case 3:
                          _drawer.closeDrawer(GravityCompat.START);
  
                          break;
                      case 4:
                          _drawer.closeDrawer(GravityCompat.START);
  
                          break;
                  }
                  break;
          }
  
          return false;
      }
  });
          return convertView;
      }
  
      @Override
      public boolean hasStableIds() {
          return false;
      }
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
  
  
          return true;
      }
  
  }
  `
  </code></pre>