private int getTextAppearance(AttributeSet attrs, int defStyle) { int answer = defStyle; for(int i=0; i<attrs.getAttributeCount(); i++) { if(attrs.getAttributeNameResource(i) == android.R.attr.textAppearance) { String attrStringValue = attrs.getAttributeValue(i); if(attrStringValue != null) { attrStringValue = attrStringValue.replace("?", ""); answer = Integer.parseInt(attrStringValue); } } } return answer; }
public TimeDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); for (int i=0;i<attrs.getAttributeCount();i++) { String attr = attrs.getAttributeName(i); String val = attrs.getAttributeValue(i); if (attr.equalsIgnoreCase("step")) { Log.i("TimeDialogPreference", "step = "+val); } } }
min = Integer.parseInt(attrs.getAttributeValue(i)); } else if (attr.equals("max")) { max = Integer.parseInt(attrs.getAttributeValue(i)); } else if (attr.equals("units")) { units = attrs.getAttributeValue(i); } else if (attr.equals("defaultValue" )) { defaultValue = Integer.parseInt(attrs.getAttributeValue(i)); oldValue = defaultValue;
min = Integer.parseInt(attrs.getAttributeValue(i)); } else if (attr.equals("max")) { max = Integer.parseInt(attrs.getAttributeValue(i)); } else if (attr.equals("units")) { units = attrs.getAttributeValue(i); } else if (attr.equals("defaultValue" )) { defaultValue = Integer.parseInt(attrs.getAttributeValue(i)); oldValue = defaultValue;
public SeekBarPreference1(Context context, AttributeSet attrs) { super(context, attrs); _preferences = PreferenceManager.getDefaultSharedPreferences(context); // Save your shared prefs here // I saved the seekbar max && current value // Something like below for (int i = 0; i < attrs.getAttributeCount(); i++) { if (attrs.getAttributeName(i).equals("max")) _preferences.edit().putString(getKey() +"Max", ""+ attrs.getAttributeValue(i)).commit(); } }
if(attrName.equals("fontFamily")) this.ttfName = attrs.getAttributeValue(i); Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/"+this.ttfName); setTypeface(font);
String attr = attrs.getAttributeName(i); if ("name".equals(attr)) { mName = attrs.getAttributeValue(i); } else if ("type".equals(attr)) {
public class MyTextView extends TextView { Context context; String ttfName; public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; for (int i = 0; i < attrs.getAttributeCount(); i++) { this.ttfName = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.package.my", "ttf_name"); init(); } } private void init() { Typeface font = Typeface.createFromAsset(context.getAssets(), ttfName); setTypeface(font); } @Override public void setTypeface(Typeface tf) { super.setTypeface(tf); }
this.text = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.xyz", "text"); this.token = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.xyz", "token"); this.colorSpan = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.xyz", "colorSpan");