Hi I am working with android .I am trying to implement list view search in my application.I have an edit text and get value from that edit text and update my list view using base adapter .Now the problem is that It works perfectly upto search 4 characters. When I enter 5 th character it force closed and show index out of bound exception. I searched a lot and foud an answer "remove getcount " method. But still it doesn't solve my problem. How can I solve this issue ? Thanks in advance :)

```
 search.addTextChangedListener(new TextWatcher()
 {

 public void afterTextChanged(Editable s)
 {

 }

 public void beforeTextChanged(CharSequence s, int start,
 int count, int after)
 {

 }

 public void onTextChanged(CharSequence s, int start,
 int before, int count)
 {

 textlength = search.getText().length();
 date1.clear();
 desc1.clear();
 time1.clear();
 place1.clear();

 for (int i = 0; i < date.length; i++)
 {

 String a=search.getText().toString();
 if (a.equalsIgnoreCase((String) date[i].subSequence(0, textlength))        ||  
     a.equalsIgnoreCase((String) descriptions[i].subSequence(0, textlength))||   
     a.equalsIgnoreCase((String) time[i].subSequence(0, textlength))        ||  
     a.equalsIgnoreCase((String) place[i].subSequence(0, textlength)))
    {
     date1.add(date[i]);
     desc1.add(descriptions[i]);
     time1.add(time[i]);
     place1.add(place[i]);
    }

 }

 listView.setAdapter(new dataListAdapter(date1,desc1,place1,time1));

 }
 }); 

```

here is my log cat

```
12-04 12:56:52.786: E/AndroidRuntime(24240): java.lang.StringIndexOutOfBoundsException: length=4; regionStart=0; regionLength=5
12-04 12:56:52.786: E/AndroidRuntime(24240):     at java.lang.String.startEndAndLength(String.java:588)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at java.lang.String.substring(String.java:1475)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at java.lang.String.subSequence(String.java:1862)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at info.androidhive.tabsswipe.UpcomingEvents$1.onTextChanged(UpcomingEvents.java:89)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.widget.TextView.sendOnTextChanged(TextView.java:7419)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.widget.TextView.handleTextChanged(TextView.java:7478)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9198)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:683)
12-04 12:56:52.786: E/AndroidRuntime(24240):     at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:438)

```

here is my adapter class

```
class dataListAdapter extends BaseAdapter {
        String[]  Date, Desc,Loc, Time;

        dataListAdapter() {
            Date = null;
            Desc = null;
            Loc = null;
            Time = null;
        }

        public dataListAdapter(String[] text, String[] text1,String[] text3,String[] text4) {
            Date = text;
            Desc = text1;
            Loc = text3;
            Time = text4;

        }

        public dataListAdapter(ArrayList<String> text, ArrayList<String> text1,ArrayList<String> text2, ArrayList<String> text3) {

            Date = new String[text.size()];
            Desc = new String[text1.size()];
            Loc = new String[text2.size()];
            Time = new String[text3.size()];

            for(int i=0;i<text.size();i++)
            {
                Date[i] = text.get(i);
                Desc[i] = text1.get(i);
                Loc[i] = text2.get(i);
                Time[i] = text3.get(i);
            }

        }

        public int getCount() {

            return Date.length;
        }

        public Object getItem(int arg0) {

            return null;
        }

        public long getItemId(int position) {

            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater = getActivity().getLayoutInflater();
            View row;
            row = inflater.inflate(R.layout.event_item, parent, false);
            TextView date, desc,loc,time;

            date = (TextView) row.findViewById(R.id.date);
            desc = (TextView) row.findViewById(R.id.desc);
            loc = (TextView) row.findViewById(R.id.place);
            time = (TextView) row.findViewById(R.id.time);
            Typeface font = Typeface.createFromAsset(
                    getActivity().getAssets(),
                    "Ace.ttf");
            date .setTypeface(font);
            date.setText(Date[position]);
            desc.setText(Desc[position]);
            loc.setText(Loc[position]);
            time.setText(Time[position]);

            return (row);
        }
    }

```