原来想直接想调用程序的东西,但是使用R.styleable的时候 eclipse不能解析了,后来发现原来被删除了此方法
public ImageAdapter(Context c) {
mContext = c;
TypedArray a = obtainStyledAttributes(android.R.styleable.Theme);
mGalleryItemBackground = a.getResourceId(
android.R.styleable.Theme_galleryItemBackground, 0);
a.recycle();
}
这种方法也就不能用了
然后
public ImageAdapter(Context c) {
mContext = c;
TypedArray a = c.obtainStyledAttributes(R.styleable.Gallery1);
mGalleryItemBackground = a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0);
a.recycle();
}
唯一要做的就是自己去做一个styleable
res\values
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Gallery1">
<attr name="android:galleryItemBackground" />
</declare-styleable>
</resources>
分享到:
相关推荐
android.R.styleable 类包含所有组件相关的XML属性。
int highlightColor = a.getColor(R.styleable.com_deezapps_widget_PagerControl_highlightColor, DEFAULT_HIGHLIGHT_COLOR); fadeDelay = a.getInteger(R.styleable.com_deezapps_widget_PagerControl_fadeDelay...
在平时我们自定义view视图的时候,有时候需要根据不同的属性来改变我们布局,这样就相当做成一个像系统控件那样的模板一样,可以重复使用,就需要通过自定义属性来实现。
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommonSearchLayout, defStyleAttr, 0); hint = typedArray.getString(R.styleable.CommonSearchLayout_edit_text_hint); left_...
@AttrString(R.styleable.CustomView_test_string) String testString; @AttrString(R.styleable.CustomView_test_string2) String testString2; @AttrBool(id = R.styleable.CustomView_test_boolean, defValue = ...
android客户端动态生成验证码代码,通过此代码能够学习自定义view的实现步骤:1、自定义View的属性;2、在View的构造方法中获得我们自定义的属性;3、重写onMesure ;4、重写onDraw
里面 包含 R.styleable.AppCompatTheme这个变量,资源很有用,很全面。 这个是 ADT的项目, 好多人都在用 Android Studio了。。。可正常扫描二维码了,识别出来二维码的信息。 并且该项目是完整的源码:里面包含...
class CustomView (...) : View(...) { @ColorAttr( R .styleable. CustomView_bgColor ) var bgColor : Int = Color . RED @DimensionAttr( R .styleable. CustomView_radius ) var radius : Float = 0f var text ...
This tool will remove all the class in R.java except the styleable class and replace the referance into the constant value. So you can reduce the dex files number and apk size. The plugin has been ...
主要介绍了Android自定义DataGridView数据表格控件的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
android.internal.R.styleable.TextView_textScaleX setTextScaleX(a.getFloat(attr, 1.0f)); 行间距 Android系统中TextView默认显示中文时会比较紧凑,不是很美观。为了让每行保持一定的行间距,可以设置属性...
Android包下面android.R.styleable类包含下面所有组件相关的XML属性。如:publicstaticfinalint[]LinearLayout_Layouthttp://www.blogjava.net/zhip/archive/2011/01/25/343511.html Android包下面android.R....
custom="http://schemas.android.com/apk/res/com.xs.justifytextview" custom:lineSpacing="10sp" TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.JustifyTextView, defStyle,...
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CircleTextProgressbar); if (typedArray.hasValue(R.styleable.CircleTextProgressbar_in_circle_color)) inCircleColors =...
Android Gallery控件的主要功能就是实现图片的浏览。 代码片段: public class ImageAdapter extends BaseAdapter { ... TypedArray a = obtainStyledAttributes(R.styleable.Gallery); mGallerystyle
本文实例为大家分享了Android折线走势图的具体代码,供... TypedArray typedArray = getContext().obtainStyledAttributes(attrs,R.styleable.High_LowChartView); mTextSize = (int)typedArray.getDimension(R.styl
本文实例为大家介绍了Android自定义视图属性的方法,供大家参考,具体内容如下 1. 自定义一个自己的视图类继承自... TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.MyView); int color=ta.getColo
:shortcake: CakeCutter 一个微小的注释库,用于将样式化的属性注入到自定义视图中。例子加载样式属性的...ctx.obtainStyledAttributes(attrs, R .styleable. CustomView ) try { customText = styledAttrs.getStrin
导入属性到attrs.xml中<declare-styleable name="RopeProgressBar"> name="max" format="integer"/> name="progress" format="integer"/> name="primaryColor" format="color"/> name=...
</declare-styleable>使用ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setAdapter(new ViewPagerAdapter()); FlymeTabStrip tabStrip = (FlymeTabStrip) ...