Studiare po 'di codice (noto per essere buono) Riesco a vedere la logica come segue:getLayoutInflater vs LayoutInflater.from
if (getContext() instanceof Activity) {
inflater=((Activity)getContext()).getLayoutInflater();
}
else {
inflater=LayoutInflater.from(getContext());
}
mi domando, perché questo if/else
, come è meglio, semplicemente, utilizzando LayoutInflater.from
in tutti i casi?
Ci sono delle variazioni su come ottenere LayoutInflater, ma sono tutte uguali. LayoutInflater inflater1 = context.getLayoutInflater(); LayoutInflater inflater2 = context.getWindow(). GetLayoutInflater(); LayoutInflater inflater3 = LayoutInflater.from (context); LayoutInflater inflater4 = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); – HendraWD