Saturday 21 March 2015

Android: ListView with Filterable List and Animation



Adding demo here to create ListView with Filterable List.


  • ListView
  • Filterable Interface
  • Animation ListView






For adding filterable ListView we have to implement Filterable interface in our Adapter class.
And define getFilter() method of this interface.


For Example:


@Override
public Filter getFilter() {

return new Filter() {

@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
/*
*Notify listview to populate new list after filtering
*/
notifyDataSetChanged();
}

/* (non-Javadoc)
* constraint : String to filter result
* return  FilterResults to populate on listview
*/
@Override
protected FilterResults performFiltering(CharSequence constraint) {
/*
*Here we will get string to filter result from current list.
*We can create new result data to populate on listview. 
*/
                  return resultData;
}
};
}


For adding animation into ListView we have to create animation xml and put it into anim folder inside res directory 
Now we can add this animation into ListView using below code:

listView.setAnimation(AnimationUtils.loadAnimation(LauncherActivity.this, R.anim.alpha));


For detail download example and see inline comment.

You can download demo code from below url:



3 comments:

  1. I don't have newsletter but if you want you can add me on google+ or add me on your blogger account.

    Thanks for your comment.

    ReplyDelete
  2. Thank and valuable information dude !!
    you can check my blog where you can get all information about technology, tips and trick, free source code of Android and Java - Tell Me How - A place for Technology geekier

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete