本文整理汇总了Java中android.support.v4.view.LayoutInflaterFactory类的典型用法代码示例。如果您正苦于以下问题:Java LayoutInflaterFactory类的具体用法?Java LayoutInflaterFactory怎么用?Java LayoutInflaterFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LayoutInflaterFactory类属于android.support.v4.view包,在下文中一共展示了LayoutInflaterFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attach
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的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);
}
}
示例2: ReplaceSystemControls
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
public void ReplaceSystemControls() {
LayoutInflaterCompat.setFactory(LayoutInflater.from(this), new LayoutInflaterFactory() {
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
// /**
// * 可以在这里将系统类替换为自定义View,不要在这里做处理,到相应的类中复写该方法
// */
// if (name.equals("ImageView")) {
// return new Button(context, attrs);
// }
return getDelegate().createView(parent, name, context, attrs);
}
});
}
示例3: installViewFactory
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
public void installViewFactory(@Nullable LayoutInflaterFactory delegateFactory) {
this.delegateFactory = delegateFactory;
LayoutInflater layoutInflater = LayoutInflater.from(activity);
if (layoutInflater.getFactory() == null) {
LayoutInflaterCompat.setFactory(layoutInflater, this);
} else {
Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed"
+ " so we can not install AppCompat's");
}
}
示例4: TypefaceCompatFactory
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
private TypefaceCompatFactory(Context context, boolean typefaceDetectionEnabled) {
TypefaceCompat.initialize(typefaceDetectionEnabled);
try {
this.mBaseFactory = (LayoutInflaterFactory) ((AppCompatActivity) context).getDelegate();
} catch (ClassCastException e) {
e.printStackTrace();
}
}
示例5: init
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
/**
* 初始化夜间控制器
* @param activity 上下文
* @return
*/
public ChangeModeController init(final Activity activity,final Class mClass){
init();
LayoutInflaterCompat.setFactory(LayoutInflater.from(activity), new LayoutInflaterFactory() {
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
View view = null;
try {
if(name.indexOf('.') == -1){
if ("View".equals(name)) {
view = LayoutInflater.from(context).createView(name, "android.view.", attrs);
}
if (view == null) {
view = LayoutInflater.from(context).createView(name, "android.widget.", attrs);
}
if (view == null) {
view = LayoutInflater.from(context).createView(name, "android.webkit.", attrs);
}
}else{
if (view == null){
view = LayoutInflater.from(context).createView(name, null, attrs);
}
}
if(view != null){
// Log.e("TAG", "name = " + name);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
// Log.e("TAG", attrs.getAttributeName(i) + " , " + attrs.getAttributeValue(i));
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND)) {
mBackGroundViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_TWO_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_THREE_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND_DRAWABLE)) {
mBackGroundDrawableViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
}
}
}
}catch (Exception e){
e.printStackTrace();
}
return view;
}
});
return this;
}
示例6: getLayoutInflaterFactory
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
LayoutInflaterFactory getLayoutInflaterFactory() {
return this;
}
示例7: InflaterHandler
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
public InflaterHandler(LayoutInflaterFactory inflaterFactory, AppCompatActivity activity) {
this.inflaterFactory = inflaterFactory;
this.activity = activity;
}
示例8: init
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
/**
* 初始化夜间控制器
* @param activity 上下文
* @return
*/
public ChangeModeController init(final Activity activity, final Class mClass){
init();
LayoutInflaterCompat.setFactory(LayoutInflater.from(activity), new LayoutInflaterFactory() {
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
View view = null;
try {
if(name.indexOf('.') == -1){
if ("View".equals(name)) {
view = LayoutInflater.from(context).createView(name, "android.view.", attrs);
}
if (view == null) {
view = LayoutInflater.from(context).createView(name, "android.widget.", attrs);
}
if (view == null) {
view = LayoutInflater.from(context).createView(name, "android.webkit.", attrs);
}
}else{
if (view == null){
view = LayoutInflater.from(context).createView(name, null, attrs);
}
}
if(view != null){
// Log.e("TAG", "name = " + name);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
// Log.e("TAG", attrs.getAttributeName(i) + " , " + attrs.getAttributeValue(i));
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND)) {
mBackGroundViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_TWO_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_THREE_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
}
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND_DRAWABLE)) {
mBackGroundDrawableViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
}
}
}
}catch (Exception e){
e.printStackTrace();
}
return view;
}
});
return this;
}
示例9: getLayoutInflaterFactory
import android.support.v4.view.LayoutInflaterFactory; //导入依赖的package包/类
LayoutInflaterFactory getLayoutInflaterFactory()
{
return this;
}