3

I have been looking around on SO and GitHub to find a convenient way to search through my RecyclerView.

I have found this project: Searchable RecyclerView

This is the GitHub repo: repo

And this is a SO answer that explains how to use it: answer

It seems really easy to use but in the ViewHolder.class there is this code:

private final ItemExampleBinding mBinding;

with this ItemExampleBinding object, that isn't mentioned anywhere, not on SO, nor on GitHub, nor on the project Homepage.

Have any of you used this Library before and can explain to me what this Object is and how to create it?

Thank you in advance.

Community
  • 1
  • 1
Daniele
  • 4,163
  • 7
  • 44
  • 95

2 Answers2

1

This class ItemExampleBinding is auto-generated from Data Binding.

Android provides one library that Binds data to it's view. It uses MVVM pattern instead of traditional MVP pattern in Android.

Traditional Way:

  1. Inflating XML layout in the activity
  2. Finding the element in the layout by using a method such as findViewbyID,
  3. Assigning the element to a local variable,
  4. Getting value from the data, and
  5. Assigning value to an element property.

Using DataBinding library:

  1. Create a binding from a layout
  2. Retrieve the data
  3. Bind the data to the view

For more information, please check references below:

https://developer.android.com/topic/libraries/data-binding/index.html http://www.developer.com/ws/android/programming/how-to-use-android-data-binding.html

Thank You!

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
  • Thank you for the answer. Since my app has been under development for a while now and I prefer not to change the whole code as required by Data Binding is there a way I can use this library without data binding or another library that does the same thing? – Daniele Dec 23 '16 at 10:49
  • @Daniele: Yes you can use same library. You have issue in generating that class. Please clean or rebuild project which will clear the error! – AndiGeeky Dec 23 '16 at 10:53
  • I tried both, cleaning and rebuilding but I still get "cannot resolve symbol: ItemExampleBinding" – Daniele Dec 23 '16 at 12:01
  • @Daniele: Can you just remove library and import again. As There may be some issue for library to generate build files! – AndiGeeky Dec 24 '16 at 05:37
0

//It is DataBinding error you do clean and build project to resolve that otherwise rename databinding in xml layout

//I have just implement and work perfect

vasupujy
  • 442
  • 2
  • 11