Closed ZhouBey closed 2 years ago
@ZhouBey Yes, manually created views cannot get updated using this library, basically you need to updated their text manually using setText(...)
whenever you change the Resources
in any way. Support for manually created views out of the box is not something I have planned to support, it would be a pretty big change. Feel free to work on it though, I take PRs :)
yeah, null of attrsTag by manually creating views,so is there any way to achieve it? or do you have any ideas?thank you.
I think there are two approaches:
First it to set the attrsTag manually whenever setText
is called. Basically add ViewCreator
s which replace views with custom views subclassed from the same view, which have the setText function overwritten to just set add the attrsTag manually. Notice that this change will require you to always use the setText
which takes a resource string id as parameter.
Another approach would be to add a new function to register view updates to reword. Now you just need to keep the mapping of views to view update functions in memory and get and execute this function whenever Reword.reword encounters the corresponding view.
Both approaches will take considerate effort. I think you will be faster by just doing it manually, but if you want to contribute I would accept a PR for both approaches. I think the second one is preferably though. While less generic, it would be more transparent for the user of the lib how to use the feature.
I understand, thank you
i can not reword text when i create a instance of TextView in Activity,alse i called setText(getString(...))