On Feb 22, 3:08 pm, "cool.manish" <mannishga...@gmail.com> wrote:
> Hi All,
>
> I have a ListView, which is having data in the form of HashMap<String,
> String>. I am populating the list as
>
> SimpleAdapter adapter = new SimpleAdapter(ctx, myData,
> R.layout.my_layout, keys, ids));
> listview.setAdapter(adapter);
>
> In my_layout.xml, I have set 2 TextViews(which will be the row of the
> listview). So the list row will look something like
>
> Abc AbcData
> Xyz XyzData
>
> Now, I want to include text filter this list. For this I have impleted
> TextWatcher,
>
> private TextWatcher filterTextWatcher = new TextWatcher() {
> @Override
> public void beforeTextChanged(CharSequence s, int start, int count,int
> after) {}
>
> @Override
> public void onTextChanged(CharSequence s, int start, int before,int
> count){
> adapter.getFilter().filter(s);}
>
> @Override
> public void afterTextChanged(Editable s) {}
> };
>
> @Override
> protected void onDestroy()
> {
> super.onDestroy();
> filterText.removeTextChangedListener(filterTextWatcher);
>
> }
>
> The filter is working ok. But the problem is I am getting 2 rows for
> each search. Say if I type 'A' I am getting 2 rows(same content though
> in the original list there is only one row)
> Abc AbcData
> Abc AbcData
>
> I assume that it is filtering first on Text1(i.e. Abc) and then on
> Text2(i.e. AbcData) and hence I am getting two rows.
>
> So can anyone advise how should I tackle this problem and get only one
> row.
>
> Thanks in advance,
> ~Manish.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment