It's seen that you can call findViewyId(R.id.temp)
inside activity java code when the id temp
is of a view present inside a fragment inflated in that activity.
I want to know the use cases where this can be useful.
One case is let us assume there is a view V1 inside a fragment F which is being used by two activities A and B. Then if you have a case where you have to do a specific operation O1 on V1 for A and a different operation O2 on V1 for B, then instead of writing O1 and O2 inside fragment's code using if else checks for activities, you can simply let activities write the operations inside their respective java codes. I think this will be a good design pattern.
Aucun commentaire:
Enregistrer un commentaire