`
wang_peng1
  • 浏览: 3900014 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

关于R.styleable的问题

阅读更多

原来想直接想调用程序的东西,但是使用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>

分享到:
评论
1 楼 pimkle 2013-03-17  
照楼主的方法做了, 编译果然通过了, 程序运行的时候照样挂...可能是源代码有问题

相关推荐

    android.R.styleable 类包含 XML属性

    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...

    android 自定义view-styleable 的使用

    在平时我们自定义view视图的时候,有时候需要根据不同的属性来改变我们布局,这样就相当做成一个像系统控件那样的模板一样,可以重复使用,就需要通过自定义属性来实现。

    自定义searchiew

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommonSearchLayout, defStyleAttr, 0); hint = typedArray.getString(R.styleable.CommonSearchLayout_edit_text_hint); left_...

    java7源码-AttrButterKnife:自定义属性的Butterknife

    @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生成动态验证码代码

    android客户端动态生成验证码代码,通过此代码能够学习自定义view的实现步骤:1、自定义View的属性;2、在View的构造方法中获得我们自定义的属性;3、重写onMesure ;4、重写onDraw

    android 扫描二维码 [android-support-v7-appcompat] eclipse的完整项目

    里面 包含 R.styleable.AppCompatTheme这个变量,资源很有用,很全面。 这个是 ADT的项目, 好多人都在用 Android Studio了。。。可正常扫描二维码了,识别出来二维码的信息。 并且该项目是完整的源码:里面包含...

    Tablespoon:使用注解在您的自定义视图中轻松绑定属性

    class CustomView (...) : View(...) { @ColorAttr( R .styleable. CustomView_bgColor ) var bgColor : Int = Color . RED @DimensionAttr( R .styleable. CustomView_radius ) var radius : Float = 0f var text ...

    Android代码-apk 瘦身之去除 R.class

    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自定义DataGridView数据表格控件的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

    android textview设置字体的行距和字间距

    android.internal.R.styleable.TextView_textScaleX setTextScaleX(a.getFloat(attr, 1.0f)); 行间距 Android系统中TextView默认显示中文时会比较紧凑,不是很美观。为了让每行保持一定的行间距,可以设置属性...

    Androidlayoutxml总结

    Android包下面android.R.styleable类包含下面所有组件相关的XML属性。如:publicstaticfinalint[]LinearLayout_Layouthttp://www.blogjava.net/zhip/archive/2011/01/25/343511.html   Android包下面android.R....

    justifyTextView

    custom="http://schemas.android.com/apk/res/com.xs.justifytextview" custom:lineSpacing="10sp" TypedArray a = context.getTheme().obtainStyledAttributes(attrs,R.styleable.JustifyTextView, defStyle,...

    应用启动页自定义跳转计时器View Demo

    TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CircleTextProgressbar); if (typedArray.hasValue(R.styleable.CircleTextProgressbar_in_circle_color)) inCircleColors =...

    Android Gallery控件实现图片浏览源代码

    Android Gallery控件的主要功能就是实现图片的浏览。 代码片段:   public class ImageAdapter extends BaseAdapter { ... TypedArray a = obtainStyledAttributes(R.styleable.Gallery); mGallerystyle

    Android实现折线走势图

    本文实例为大家分享了Android折线走势图的具体代码,供... TypedArray typedArray = getContext().obtainStyledAttributes(attrs,R.styleable.High_LowChartView); mTextSize = (int)typedArray.getDimension(R.styl

    Android如何自定义视图属性

    本文实例为大家介绍了Android自定义视图属性的方法,供大家参考,具体内容如下 1. 自定义一个自己的视图类继承自... TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.MyView); int color=ta.getColo

    cakecutter::shortcake:一个微小的android注释库,用于将样式化的属性注入自定义视图

    :shortcake: CakeCutter 一个微小的注释库,用于将样式化的属性注入到自定义视图中。例子加载样式属性的...ctx.obtainStyledAttributes(attrs, R .styleable. CustomView ) try { customText = styledAttrs.getStrin

    RopeProgressBar-一个带有松弛特效的进度条.zip

    导入属性到attrs.xml中&lt;declare-styleable name="RopeProgressBar"&gt;   name="max" format="integer"/&gt;   name="progress" format="integer"/&gt;   name="primaryColor" format="color"/&gt;   name=...

    FlymeTabStrip-自定义实现Flyme6的ViewPager指示器.zip

     &lt;/declare-styleable&gt;使用ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setAdapter(new ViewPagerAdapter()); FlymeTabStrip tabStrip = (FlymeTabStrip) ...

Global site tag (gtag.js) - Google Analytics