Avocarrot / json2view

Update native Android UI on the fly
MIT License
1.51k stars 281 forks source link

Support get view's id from IdMap #33

Closed BrandonTsai closed 2 years ago

BrandonTsai commented 8 years ago

By calling DynamicView.getIdMap(), user can get child view via findViewById(idMap.get("id_name").intValue());

tsiougkosn commented 7 years ago

Hi @BrandonTsai ,

Thanks for your suggestions. I think we need a better approach to return the map of <String,Int> because as the createView is a static it is not good to keep the ids in a variable in the class. We need to return in similar way we return the view. What do you think about that ?

Nikos

BrandonTsai commented 7 years ago

Hi @tsiougkosn ,

How about return a DynamicView object which contain the view and the ids when user call DynamicView.createView()?

For example:

DynamicView dynamicView = DynamicView.createView(this, jsonObject, SampleViewHolder.class);
View sampleView = dynamicView.getView();
HashMap<String, Integer> idMap = dynamicView.getIds();