本文整理汇总了Java中android.util.AttributeSet.getAttributeName方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.getAttributeName方法的具体用法?Java AttributeSet.getAttributeName怎么用?Java AttributeSet.getAttributeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.getAttributeName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFonts
import android.util.AttributeSet; //导入方法依赖的package包/类
private void loadFonts(Context context, @Nullable AttributeSet attrs) {
_defaultValue = _fontValues[0];
if (attrs != null) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attrName = attrs.getAttributeName(i);
String attrValue = attrs.getAttributeValue(i);
if (attrName.equalsIgnoreCase("defaultValue")) {
if (attrValue.startsWith("@")) {
int resId = Integer.valueOf(attrValue.substring(1));
attrValue = getContext().getString(resId);
}
_defaultValue = attrValue;
break;
}
}
}
setDefaultValue(_defaultValue);
setEntries(_fontNames);
setEntryValues(_fontValues);
}
示例2: SeekBarPreference
import android.util.AttributeSet; //导入方法依赖的package包/类
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_seekbar);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("pref_kind")) {
prefKind = attrs.getAttributeValue(i);
break;
}
}
if (prefKind.equals("pref_open_delay")) {
hintText = getContext().getString(R.string.delay_open);
} else if (prefKind.equals("pref_comment_delay")) {
hintText = "发送回复(暂不支持延时)";
}
}
示例3: ELABORATE_FEED_REPORT
import android.util.AttributeSet; //导入方法依赖的package包/类
public ELABORATE_FEED_REPORT(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_seekbar);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("pref_kind")) {
prefKind = attrs.getAttributeValue(i);
break;
}
}
}
示例4: NS_MOBILE_EXTRA
import android.util.AttributeSet; //导入方法依赖的package包/类
public NS_MOBILE_EXTRA(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_seekbar);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("pref_kind")) {
prefKind = attrs.getAttributeValue(i);
break;
}
}
}
示例5: getAttrs
import android.util.AttributeSet; //导入方法依赖的package包/类
/**
* 把这个View的属性中需要的(SkinType, entryName)对取出来(作为SkinAttr类)
* @param context
* @param attrs
* @return
*/
public static List<SkinAttr> getAttrs(Context context, AttributeSet attrs) {
//把background、src、textColor解析出来
List<SkinAttr> result = new ArrayList<>();
//开始解析所有属性
int length = attrs.getAttributeCount();
for (int i=0; i<length; i++){
//获取属性名称
String name = attrs.getAttributeName(i);
//获取属性值
String value = attrs.getAttributeValue(i);
//Log.e(TAG, name + " "+ value);
//检查是否存在所需属性名称
SkinType skinType = getTargetSkinType(name);
//如果是所需要的属性名
if(skinType != null){
//获取属性值名称
String resName = getResName(context, value);
if(TextUtils.isEmpty(resName)){
continue;
}
SkinAttr attr = new SkinAttr(resName, skinType);
result.add(attr);
}
}
return result;
}
示例6: CameraPreviewUVC
import android.util.AttributeSet; //导入方法依赖的package包/类
public CameraPreviewUVC(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusable(true);
this.holder = getHolder();
this.holder.addCallback(this);
mUsbMonitor = new USBMonitor(context, mOnDeviceConnectListener);
refreshDevice();
int n = attrs.getAttributeCount();
if (n <= 0) {
mCameraId = 0;
} else {
for (int i = 0; i < n; i++) {
String name = attrs.getAttributeName(i);
String value = attrs.getAttributeValue(i);
if (name == null || value == null) {
continue;
}
if (name.equals("camType") && value.equals("front")) {
mIsFront = true;
}
// camera id
if (name.equals("camId")) {
mCameraId = Integer.parseInt(value);
}
if (mCameraId < 0) {
mCameraId = 0;
}
// width
if (name.equals("width")) {
mWidth = Integer.parseInt(value);
}
// height
if (name.equals("height")) {
mHeight = Integer.parseInt(value);
}
if (mWidth <= 0 || mHeight <= 0) {
Log.d(TAG, "Wrong preview size "+mWidth+"x"+mHeight);
}
// scaleType
if (name.equals("scaleType")) {
if (value.equals("center")) {
mScaleType = SCALE_TYPE_CENTER;
} else if (value.equals("centerCrop")) {
mScaleType = SCALE_TYPE_CENTER_CROP;
} else {
mScaleType = SCALE_TYPE_FIT;
}
}
}
}
}
示例7: CameraPreviewV4L
import android.util.AttributeSet; //导入方法依赖的package包/类
public CameraPreviewV4L(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusable(true);
this.holder = getHolder();
this.holder.addCallback(this);
int n = attrs.getAttributeCount();
if (n <= 0) {
mCameraId = 0;
} else {
for (int i = 0; i < n; i++) {
String name = attrs.getAttributeName(i);
String value = attrs.getAttributeValue(i);
if (name == null || value == null) {
continue;
}
if (name.equals("camType") && value.equals("front")) {
mIsFront = true;
}
// camera id
if (name.equals("camId")) {
mCameraId = Integer.parseInt(value);
}
if (mCameraId < 0) {
mCameraId = 0;
}
// width
if (name.equals("width")) {
mWidth = Integer.parseInt(value);
}
// height
if (name.equals("height")) {
mHeight = Integer.parseInt(value);
}
if (mWidth <= 0 || mHeight <= 0) {
Log.d(TAG, "Wrong preview size "+mWidth+"x"+mHeight);
}
// scaleType
if (name.equals("scaleType")) {
if (value.equals("center")) {
mScaleType = SCALE_TYPE_CENTER;
} else if (value.equals("centerCrop")) {
mScaleType = SCALE_TYPE_CENTER_CROP;
} else {
mScaleType = SCALE_TYPE_FIT;
}
}
}
}
}
示例8: CameraPreviewNormal
import android.util.AttributeSet; //导入方法依赖的package包/类
public CameraPreviewNormal(Context context, AttributeSet attrs) {
super(context, attrs);
setSurfaceTextureListener(this);
int orient = context.getResources().getConfiguration().orientation;
if (orient == Configuration.ORIENTATION_LANDSCAPE) {
mPreviewOrient = 0;
} else if (orient == Configuration.ORIENTATION_PORTRAIT) {
mPreviewOrient = 90;
}
int n = attrs.getAttributeCount();
if (n <= 0) {
mCameraId = 0;
} else {
for (int i = 0; i < n; i++) {
String name = attrs.getAttributeName(i);
String value = attrs.getAttributeValue(i);
if (name == null || value == null) {
continue;
}
// camera id
if (name.equals("camType")) {
if (value.equals("front")) {
mCameraId = getCamId(CameraInfo.CAMERA_FACING_FRONT);
} else {
mCameraId = getCamId(CameraInfo.CAMERA_FACING_BACK);
}
}
if (mCameraId < 0) {
mCameraId = 0;
}
// width
if (name.equals("width")) {
mWidth = Integer.parseInt(value);
}
// height
if (name.equals("height")) {
mHeight = Integer.parseInt(value);
}
if (mWidth <= 0 || mHeight <= 0) {
Log.d(TAG, "Wrong preview size "+mWidth+"x"+mHeight);
}
// scaleType
if (name.equals("scaleType")) {
if (value.equals("center")) {
mScaleType = SCALE_TYPE_CENTER;
} else if (value.equals("centerCrop")) {
mScaleType = SCALE_TYPE_CENTER_CROP;
} else {
mScaleType = SCALE_TYPE_FIT;
}
}
}
} // else
}