Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@AndroidActivity and @AndroidFragment magic @+id/name -> View name field generation broken for @CustomView(Groups) #69

Open
Buggaboo opened this issue Feb 18, 2015 · 5 comments

Comments

@Buggaboo
Copy link
Contributor

A field should be generated on the custom ViewGroup, Fragment and Activity according to the @+id/name provided in the layout/viewgroup.xml, also custom Views and ViewGroups.

Right now it only works for anything from android.widget.*, but not for any other derived types, i.e. custom Views.
I recall that the

isAssignable(ViewType, View)

in the generator code should handle all types deriving from View or ViewGroup.

I'll have a look.

@Buggaboo Buggaboo changed the title @AndroidActivity and @AndroidFragment magic @+id/name -> View name field generation broken for CustomView(Groups) @AndroidActivity and @AndroidFragment magic @+id/name -> View name field generation broken for @CustomView(Groups) Feb 18, 2015
@tobykurien
Copy link
Owner

I haven't tested this issue yet, but it may be related to a change I made to prevent CardView from crashing the build: 3e5f805

@Buggaboo
Copy link
Contributor Author

Aha, thanks for the heads up. That try catch interrupts my isAssignableFrom.
What is the problem exactly with CardView?

@tobykurien Do you think the isAssignableFrom can be extended to include CardView?

Two birds one stone? Two girls one cup?

@tobykurien
Copy link
Owner

IIRC the default constructor of CardView always throws an exception, thus breaking the code. I worked around it by ignoring CardView specifically, i.e. it will not be auto-generated into the code, but is still accessible the old-fashioned way using findViewById or by adding an @AndroidView for it.

@maannajjar
Copy link
Contributor

Hey all,
I faced this issue as well after updating Xtend to 2.8.1 (from 2.7). @Buggaboo 's fix didn't resolve the issue for me, it still won't generate getter for my custom views. I did further investigation and noticed Class.forName is always throwing ClassNotFoundException for my view classes. However, I tried using findTypeGlobally and it worked.
Here's my change that made it work
maannajjar@f111e39

@tobykurien
Copy link
Owner

Thanks, @maannajjar - please send that as a pull request and I'll merge it. I'm also still having issues with cardview and custom views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants