I try to inflate a layout multiple times to be inserted inside another layout. Here is the code:
View oldView = null;
for (ProfileServiceCategory.ProfileService service : profileServiceCategory.getServices()) {
View view = LayoutInflater.from(context)
.inflate(R.layout.profile_service_list_item, viewHolder.rootView);
if(oldView == view) {
Log.d("test", "Error");
}
oldView = view;
TextView serviceName = (TextView) view.findViewById(R.id.profile_services_name);
serviceName.setText(service.getServiceValue());
}
The problem that I'm facing is the view variable that is being returned by inflate method is always the first inflated view. To be clear I added a Log.d , if everything worked as expected it should have been never called but it does hit.
I checked the view hierarchy and I can conform that new views in fact has been added to rootView but the reference that I get is for older view.
Aucun commentaire:
Enregistrer un commentaire