private void setTabText(MediaType mode, String text) { TextView textView = null; for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { SlidingTabStrip v = (SlidingTabStrip) mSlidingTabLayout.getChildAt(0); TextView currentTextView = (TextView) v.getChildAt(i); // currentTab.findViewById(android.R.id.text1); String currentText = currentTextView.getText().toString(); if (mode == MediaType.IMAGE && currentText.startsWith(getResources().getString(R.string.image).trim())) { textView = currentTextView; break; } if (mode == MediaType.VIDEO && currentText.startsWith(getResources().getString(R.string.video).trim())) { textView = currentTextView; break; } } if (textView != null) { textView.setText(text); } }