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

How can I set a custom attribute like R.attr.fontPath? #76

Closed
wellguimaraes opened this issue Jun 29, 2016 · 1 comment
Closed

How can I set a custom attribute like R.attr.fontPath? #76

wellguimaraes opened this issue Jun 29, 2016 · 1 comment

Comments

@wellguimaraes
Copy link

How can I set a custom attribute like R.attr.fontPath?

@zserge
Copy link
Collaborator

zserge commented Jun 29, 2016

@wellguimaraes Custom attributes normally come with custom views, thus to set them you will need to call a custom method of a custom view. Anvil allows you to call view methods directly, so if your view setter is setFontPath or something like that then you should be able to do something like:

someView(() -> {
  init(() -> {
    SomeView v = Anvil.currentView();
    v.setFontPath(R.attr.fontPath);
  });
});

Anvil knows nothing about XMLs and hidden magic behind those, but all XML attributes end up in Java code anyway. Which means as long as you know how to control/configure your views from Java - it would be no different with Anvil.

Alternatively, you may still use XMLs for layouts and Anvil for data binding (see Anvil's xml() method).

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

2 participants