本文整理匯總了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
}