R.styleable can not be resolved, why?

I have a resources.xml file located under direcotry values/ , That’s

/values/resources.xml

  • Trying to catch a click on android ListView item: android:descendantFocusability=“blocksDescendants” not working
  • Automatic popping up keyboard on start Activity
  • XML Rendering errors Android preview N
  • How to uninstall own app from /system/app?
  • Android: Difference between positive, negative, and neutral button
  • “Content view not yet Created” on Android Fragments
  • <?xml version="1.0" encoding="utf-8"?> 
    <resources> 
        <declare-styleable name="TheMissingTabWidget"> 
            <attr name="android:divider" /> 
        </declare-styleable> 
    </resources>
    

    In my java code, when I try to access this resource by R.styleable.TheMissingTabWidget , eclipse complain that styleable cannot be resolved or is not a field. Why? Why I can not access this resource? (I am using android 2.1-updated).

    Related posts:

    Using ZXing to create an android barcode scanning app
    Android - drawable with rounded corners at the top only
    View.onDraw() &mdash; when does it get called?
    Correctly disable AdMob ads
    Service and a BroadCastReceiver
    How to add BackStackEntry to BackStack if not exists
  • Gmail API access using Android
  • Using Make's 'wildcard' function in Android.mk
  • Is it possible to set an animated gif file as live wallpaper in android?
  • MenuItemCompat.getActionView always returns null
  • How do I put multiple items on the same line in a ListView?
  • Building a particular module in the android source code
  • 3 Solutions collect form web for “R.styleable can not be resolved, why?”

    plz make values/attrs.xml resources like this

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <declare-styleable name="**com.admob.android.ads.AdView**"><--- where u want to use
           <attr name="backgroundColor" format="color" />
           <attr name="TextColor" format="color" />
           <attr name="keywords" format="string" />
           <attr name="refreshInterval" format="integer" />
        </declare-styleable>
    </resources>
    

    According to the SDK Release Notes,

    The android.R.styleable class and its fields were removed from the public API, to better ensure forward-compatibility for applications. The constants declared in android.R.styleable were platform-specific and subject to arbitrary change across versions, so were not suitable for use by applications. You can still access the platform’s styleable attributes from your resources or code. To do so, declare a custom resource element using a in your project’s res/values/R.attrs file, then declare the attribute inside. For examples, see “sdk”/samples/ApiDemos/res/values/attrs.xml. For more information about custom resources, see Custom Layout Resources. Note that the android.R.styleable documentation is still provided in the SDK, but only as a reference of the platform’s styleable attributes for the various elements.

    Have a look to the ApiDemos code and the file res/values/attrs.xml

    What you need to do is declare your styleable in attrs.xml, not resources.xml. Then you’ll be able to refer to it from your code like this:

    R.styleable.TheMissingTabWidget
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.