本文整理汇总了Java中android.util.AttributeSet.getPositionDescription方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.getPositionDescription方法的具体用法?Java AttributeSet.getPositionDescription怎么用?Java AttributeSet.getPositionDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.getPositionDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLayoutManager
import android.util.AttributeSet; //导入方法依赖的package包/类
private void createLayoutManager(Context context, String className, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (className != null) {
className = className.trim();
if (className.length() != 0) {
className = getFullClassName(context, className);
try {
ClassLoader classLoader;
Constructor<? extends LayoutManager> constructor;
if (isInEditMode()) {
classLoader = getClass().getClassLoader();
} else {
classLoader = context.getClassLoader();
}
Class<? extends LayoutManager> layoutManagerClass = classLoader.loadClass(className).asSubclass(LayoutManager.class);
Object[] constructorArgs = null;
try {
constructor = layoutManagerClass.getConstructor(LAYOUT_MANAGER_CONSTRUCTOR_SIGNATURE);
constructorArgs = new Object[]{context, attrs, Integer.valueOf(defStyleAttr), Integer.valueOf(defStyleRes)};
} catch (NoSuchMethodException e) {
constructor = layoutManagerClass.getConstructor(new Class[0]);
}
constructor.setAccessible(true);
setLayoutManager((LayoutManager) constructor.newInstance(constructorArgs));
} catch (NoSuchMethodException e1) {
e1.initCause(e);
throw new IllegalStateException(attrs.getPositionDescription() + ": Error creating LayoutManager " + className, e1);
} catch (ClassNotFoundException e2) {
throw new IllegalStateException(attrs.getPositionDescription() + ": Unable to find LayoutManager " + className, e2);
} catch (InvocationTargetException e3) {
throw new IllegalStateException(attrs.getPositionDescription() + ": Could not instantiate the LayoutManager: " + className, e3);
} catch (InstantiationException e4) {
throw new IllegalStateException(attrs.getPositionDescription() + ": Could not instantiate the LayoutManager: " + className, e4);
} catch (IllegalAccessException e5) {
throw new IllegalStateException(attrs.getPositionDescription() + ": Cannot access non-public constructor " + className, e5);
} catch (ClassCastException e6) {
throw new IllegalStateException(attrs.getPositionDescription() + ": Class is not a LayoutManager " + className, e6);
}
}
}
}
示例2: onCreateView
import android.util.AttributeSet; //导入方法依赖的package包/类
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
if (!"fragment".equals(name)) {
return null;
}
String fname = attrs.getAttributeValue(null, "class");
TypedArray a = context.obtainStyledAttributes(attrs, FragmentTag.Fragment);
if (fname == null) {
fname = a.getString(0);
}
int id = a.getResourceId(1, -1);
String tag = a.getString(2);
a.recycle();
if (!Fragment.isSupportFragmentClass(this.mHost.getContext(), fname)) {
return null;
}
int containerId;
if (parent != null) {
containerId = parent.getId();
} else {
containerId = 0;
}
if (containerId == -1 && id == -1 && tag == null) {
throw new IllegalArgumentException(attrs.getPositionDescription() + ": Must specify unique android:id, android:tag, or have a parent with an id for " + fname);
}
Fragment fragment;
if (id != -1) {
fragment = findFragmentById(id);
} else {
fragment = null;
}
if (fragment == null && tag != null) {
fragment = findFragmentByTag(tag);
}
if (fragment == null && containerId != -1) {
fragment = findFragmentById(containerId);
}
if (DEBUG) {
Log.v(TAG, "onCreateView: id=0x" + Integer.toHexString(id) + " fname=" + fname + " existing=" + fragment);
}
if (fragment == null) {
int i;
fragment = Fragment.instantiate(context, fname);
fragment.mFromLayout = true;
if (id != 0) {
i = id;
} else {
i = containerId;
}
fragment.mFragmentId = i;
fragment.mContainerId = containerId;
fragment.mTag = tag;
fragment.mInLayout = true;
fragment.mFragmentManager = this;
fragment.mHost = this.mHost;
fragment.onInflate(this.mHost.getContext(), attrs, fragment.mSavedFragmentState);
addFragment(fragment, true);
} else if (fragment.mInLayout) {
throw new IllegalArgumentException(attrs.getPositionDescription() + ": Duplicate id 0x" + Integer.toHexString(id) + ", tag " + tag + ", or parent id 0x" + Integer.toHexString(containerId) + " with another fragment for " + fname);
} else {
fragment.mInLayout = true;
fragment.mHost = this.mHost;
if (!fragment.mRetaining) {
fragment.onInflate(this.mHost.getContext(), attrs, fragment.mSavedFragmentState);
}
}
if (this.mCurState >= 1 || !fragment.mFromLayout) {
moveToState(fragment);
} else {
moveToState(fragment, 1, 0, 0, false);
}
if (fragment.mView == null) {
throw new IllegalStateException("Fragment " + fname + " did not create a view.");
}
if (id != 0) {
fragment.mView.setId(id);
}
if (fragment.mView.getTag() == null) {
fragment.mView.setTag(tag);
}
return fragment.mView;
}