/** * Implements {@link LayoutInflater.Factory} interface. Inflate the {@link View} for the specified * tag name and apply custom {@link Typeface} if is required. This method first will delegate to * the {@code LayoutInflater.Factory} if it was specified on the constructor. When the {@code * View} is created, this method will call {@link CustomTypeface#applyTypeface(View, * AttributeSet)} on it. * * <p>This method can be used to delegate the implementation of {@link * LayoutInflater.Factory#onCreateView} or {@link LayoutInflater.Factory2#onCreateView}. * * @param name Tag name to be inflated. * @param context The context the view is being created in. * @param attrs Inflation attributes as specified in XML file. * @return Newly created view. * @see LayoutInflater.Factory * @see CustomTypeface#applyTypeface(View, AttributeSet) */ @Override public View onCreateView(String name, Context context, AttributeSet attrs) { String prefix = null; if (name.indexOf('.') == -1) { prefix = "android.widget."; } try { View view = null; if (mFactory != null) { view = mFactory.onCreateView(name, context, attrs); } if (view == null) { view = createView(name, prefix, context, attrs); } mCustomTypeface.applyTypeface(view, attrs); return view; } catch (ClassNotFoundException e) { return null; } }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { View view = null; if (context instanceof LayoutInflater.Factory) { view = ((LayoutInflater.Factory) context).onCreateView(name, context, attrs); } if (factory != null && view == null) { view = factory.onCreateView(name, context, attrs); } if (view == null) { view = createViewOrFailQuietly(name, context, attrs); } if (view != null) { onViewCreated(view, context, attrs); } return view; }
public View createView(String s, Context context, AttributeSet attributeset) { return customLayoutInflaterFactory.onCreateView(s, context, attributeset); }