Studiowanie trochę (wiadomo, że są dobre) kod widzę logiki w następujący sposób:getLayoutInflater vs LayoutInflater.from
if (getContext() instanceof Activity) {
inflater=((Activity)getContext()).getLayoutInflater();
}
else {
inflater=LayoutInflater.from(getContext());
}
Zastanawiam się dlaczego ten if/else
, jak to jest lepiej, po prostu, za pomocą LayoutInflater.from
w wszystkie przypadki?
Istnieją różne sposoby uzyskiwania LayoutInflater, ale wszystkie są takie same. LayoutInflater inflater1 = context.getLayoutInflater(); LayoutInflater inflater2 = context.getWindow(). GetLayoutInflater(); LayoutInflater inflater3 = LayoutInflater.from (context); LayoutInflater inflater4 = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); – HendraWD