Giter Site home page Giter Site logo

Comments (4)

KenVanHoeylandt avatar KenVanHoeylandt commented on May 23, 2024

Thank you very much!

Currently the view-binding is only supported for View/Fragment/Activity, however I'll create support for RecyclerView.ViewHolder this weekend.
I'll also add some documentation explaining basic binding examples for View, Fragment, Activity and RecyclerView.ViewHolder binding.

The documentation does explain under 'Usage' that you can bind fragments in onViewCreated(), but I already suspected that this was probably not very clear to people.

For now, I can give you a temporary work-around for your RecyclerView issue:

You could create a new custom View class that basically wraps the functionality you need. It would look something like this:

@BindLayout(R.layout.news_item_row)
public CustomView extends FrameLayout
{
    @BindView(R.id.yourview)
    private View mView;

    public CustomView(Context context)
    {
        super(context);

        Spork.bind(this);
    }
}

And then it's just business as usual:

CustomView view = new CustomView();
return new NewsRecyclerViewHolder(context, view);

I'll keep you posted on the release of the new feature and documentation over the weekend.

from spork.

KenVanHoeylandt avatar KenVanHoeylandt commented on May 23, 2024

I have published a new version (2.3.0) with the following features:

  • BindView/BindClick/BindResource/BindComponent support for RecyclerView.ViewHolder
  • no need to call SporkAndroid.initialize() anymore
  • improved Javadoc for existing annotations

Also, I have given the website a major update. It includes a whole bunch of examples including one for RecyclerView right here.

from spork.

betomaluje avatar betomaluje commented on May 23, 2024

Works perfectly! Thanks! Also, the web is really awesome.

Another problem I'm having is using Spork on PagerAdapter (to display views on a ViewPager). For now, I'm going to use your approach by creating a custom view.

from spork.

KenVanHoeylandt avatar KenVanHoeylandt commented on May 23, 2024

Good to hear! And you're welcome!
Could you open a new ticket for the PagerAdapter? I'll close this ticket now.

from spork.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.