if(sr!=null){
String str=childlist.get(groupPosition).get(childPosition).getTitle(); int indexOf = str.indexOf(sr); if(indexOf != -1){ int end = indexOf+sr.length(); SpannableStringBuilder builder = new SpannableStringBuilder(str ); ForegroundColorSpan redSpan = new ForegroundColorSpan(Color.RED); builder.setSpan(redSpan, indexOf, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); itemtitle.setText(builder); }