本文整理汇总了Java中android.support.v4.view.LayoutInflaterCompat类的典型用法代码示例。如果您正苦于以下问题:Java LayoutInflaterCompat类的具体用法?Java LayoutInflaterCompat怎么用?Java LayoutInflaterCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LayoutInflaterCompat类属于android.support.v4.view包,在下文中一共展示了LayoutInflaterCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createView
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
/**
* Creates the view for the given fragment. This will trigger {@link
* me.tatarka.simplefragment.SimpleFragment#onCreateView(LayoutInflater, ViewGroup)}
* immediately. This will <em>not</em> occur automatically on configuration changes, you are
* responsible for calling it again in those cases.
*
* @param fragment The {@code SimpleFragment} to createView.
* @throws java.lang.IllegalArgumentException If the given fragment is null or was not added to
* this manager.
*/
public View createView(SimpleFragment fragment, LayoutInflater layoutInflater, @Nullable ViewGroup parentView) {
if (fragment == null) {
throw new IllegalArgumentException("SimpleFragment cannot be null.");
}
if (!fragments.contains(fragment)) {
throw new IllegalArgumentException("Attempting to createView fragment that was not added: '" + fragment + "'");
}
if (fragment.getView() != null) {
throw new IllegalArgumentException("Attempting to createView fragment that has already been attached.");
}
// To support <fragment> tags in nested layouts, we need a custom inflater.
LayoutInflater fragmentInflater = layoutInflater.cloneInContext(activity);
LayoutInflaterCompat.setFactory(fragmentInflater, new SimpleFragmentViewInflater(fragment.getSimpleFragmentManager()));
return fragment.createView(fragmentInflater, parentView);
}
示例2: installPandroidViewFactory
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
public static void installPandroidViewFactory(AppCompatActivity compatActivity) {
List<LayoutInflater.Factory2> factories = new ArrayList<>();
if (compatActivity instanceof PandroidFactoryProvider) {
addProviderFactories((PandroidFactoryProvider) compatActivity, factories);
}
if (compatActivity.getApplication() instanceof PandroidFactoryProvider) {
addProviderFactories((PandroidFactoryProvider) compatActivity.getApplication(), factories);
}
if (!factories.isEmpty()) {
LayoutInflater inflater = LayoutInflater.from(compatActivity);
if (inflater.getFactory2() == null) {
PandroidViewFactory factory = new PandroidViewFactory(compatActivity.getDelegate(), factories);
LayoutInflaterCompat.setFactory2(inflater, factory);
} else {
LogcatLogger.getInstance().w(TAG, "can't set layout inflater factory");
}
} else {
LogcatLogger.getInstance().w(TAG, "Your activity or application should implement PandroidFactoryProvider to install PandroidLayoutInflaterFactory");
}
}
示例3: setCustomTheme
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
public static void setCustomTheme(Context context, SparseIntArray customAttrs) {
if (customAttrs == null || customAttrs.size() == 0) {
currentAttrs = null;
return;
}
TypedValue tmp = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, tmp, true);
int textColorPrimaryOriginal = (tmp.type >= TypedValue.TYPE_FIRST_COLOR_INT && tmp.type <= TypedValue.TYPE_LAST_COLOR_INT) ?
tmp.data : Color.TRANSPARENT;
int textColorPrimaryOverridden = customAttrs.get(android.R.attr.textColorPrimary, textColorPrimaryOriginal);
try {
processWindow(context, customAttrs, textColorPrimaryOriginal, textColorPrimaryOverridden);
} catch (Exception e) {
Logger.e(TAG, e);
}
CustomThemeHelper instance = new CustomThemeHelper(context, customAttrs, textColorPrimaryOriginal, textColorPrimaryOverridden);
LayoutInflaterCompat.setFactory(instance.inflater, instance);
currentAttrs = customAttrs;
}
示例4: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (needAnimator()) {
AnimatorManager.setConfig(new AnimatorConfig.Builder()
.textviewVisibleAnimationType(ViewAnimatorType.AlphaHideAnimator)
.textviewTextAnimationType(ViewAnimatorType.AlphaUpdateAnimator)
.imageviewVisibleAnimationType(ViewAnimatorType.AlphaHideAnimator)
.build());
}
LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate());
super.onCreate(savedInstanceState);
}
示例5: hookLayoutInflater
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
private void hookLayoutInflater(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
try {
Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
field.setAccessible(true);
field.setBoolean(layoutInflater, false);
LayoutInflaterCompat.setFactory2(layoutInflater, AndroidSkinFactory.from(context,layoutInflater));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例6: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory2(getLayoutInflater(), new ThemedViewFactory(this));
mCurrentPrimaryColor = ThemeHelper.getPrimaryColor(this);
mCurrentAccentColor = ThemeHelper.getAccentColor(this);
super.onCreate(savedInstanceState);
applyStatusBarColor();
if (ThemeHelper.hasCustomPrimaryColor(this) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setTaskDescription(new ActivityManager.TaskDescription(null, null,
mCurrentPrimaryColor));
}
}
示例7: installViewFactory
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
public void installViewFactory() {
LayoutInflater layoutInflater = LayoutInflater.from(this.mContext);
if (layoutInflater.getFactory() == null) {
LayoutInflaterCompat.setFactory(layoutInflater, this);
} else if (!(LayoutInflaterCompat.getFactory(layoutInflater) instanceof AppCompatDelegateImplV7)) {
Log.i("AppCompatDelegate", "The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's");
}
}
示例8: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected final void onCreate(@Nullable Bundle savedInstanceState) {
// define the IconicsLayoutInflater
// this is compatible with calligraphy and other libs which wrap the baseContext
LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mActivity = this;
mApplication = (PTApplication) getApplication();
mBundle = getIntent().getExtras() != null ? getIntent().getExtras() : new Bundle();
unbinder = ButterKnife.bind(this);
mLoadingView = new LoadingView(this, getLoadingMessage());
// loadState = (ILoadState) findViewById(R.id.load_state_view);
// mPTLoading = new PTLoading.Builder(this)
// .setCanceledOnTouchOutside(false)
// .setIcon(R.drawable.button_loading_icon)
// .setMsg(getString(R.string.loading_data))
// .build();
// mPTToast = new PTToast.Builder(this)
// .setShowTime(1300)
// .build();
if (useEventBus())
EventBusUtils.register(this);
onViewCreated(savedInstanceState);
}
示例9: installLayoutFactory
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
private void installLayoutFactory(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
try {
Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
field.setAccessible(true);
field.setBoolean(layoutInflater, false);
LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例10: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate());
super.onCreate(savedInstanceState);
updateStatusBarColor();
updateWindowBackground();
}
示例11: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
skinFactory = new SkinFactory(ApkSkin.path);
LayoutInflaterCompat.setFactory(getLayoutInflater(), skinFactory);
}
示例12: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
//在setContentView之前设置好工厂
LayoutInflater layoutInflater = LayoutInflater.from(this);
LayoutInflaterCompat.setFactory(layoutInflater, this);
SkinManager.getInstance().init(this);
/*if (layoutInflater.getFactory() == null) {
LayoutInflaterCompat.setFactory(layoutInflater, this);
}*/
super.onCreate(savedInstanceState);
}
示例13: attach
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
/**
* this method should be called in Activity onCreate method,
* and before method super.onCreate(savedInstanceState);
*
* @param activity
*/
public void attach(AppCompatActivity activity) {
if (activity.getDelegate() instanceof LayoutInflaterFactory) {
LayoutInflaterFactory originInflaterFactory = (LayoutInflaterFactory) activity.getDelegate();
LayoutInflaterFactory proxyInflaterFactory = (LayoutInflaterFactory) Proxy.newProxyInstance(
originInflaterFactory.getClass().getClassLoader(),
new Class[]{LayoutInflaterFactory.class},
new InflaterHandler(originInflaterFactory, activity));
LayoutInflater layoutInflater = LayoutInflater.from(activity);
LayoutInflaterCompat.setFactory(layoutInflater, proxyInflaterFactory);
}
}
示例14: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bindView();
initView();
setupComponent();
}
示例15: onCreate
import android.support.v4.view.LayoutInflaterCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
super.onCreate(savedInstanceState);
ThemeUtil.setCustomTheme(this);
LanguageUtil.updateLanguage(this);
tintBars();
}