Get dimension from R.attr in Java code

by an0 » Sat, 19 Sep 2009 15:29:11 GMT


Sponsored Links
 Resources.getDimensionPixelSize
(android.R.attr.listPreferredItemHeight) does not work.
So how to?
And any other way to specify resolution independent dimension values
in Java code?
--~--~---------~--~----~------------~-------~--~----~



Get dimension from R.attr in Java code

by Dianne Hackborn » Sun, 20 Sep 2009 01:35:25 GMT


 You are trying to retrieve an attribute identifier as a dimension, which is
incompatible.  If you want to get the value of an attribute in the theme,
you can use the Theme class (though typically you will use
<declare-styleable> to define a set of attributes you are interested in and
retrieve them as a batch; there is an example showing this in ApiDemo's
custom view).






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Get dimension from R.attr in Java code

by an00na » Sun, 20 Sep 2009 09:28:13 GMT


 I see, but I am not initializing a custom view. Is there any simple  
way to retrieve a predefined attribute value as whatever proper type?






--
A ghost writing code with soul @  http://wangling.me/. 


--~--~---------~--~----~------------~-------~--~----~



Get dimension from R.attr in Java code

by Dianne Hackborn » Sun, 20 Sep 2009 12:44:51 GMT


 I'm just saying you need to retrieve it from the theme, and the custom view
Api demo is one example I know of doing so.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Get dimension from R.attr in Java code

by an00na » Sun, 20 Sep 2009 16:21:21 GMT


 Is it the only way? I think it is too overkill.







--
A ghost writing code with soul @  http://wangling.me/. 


--~--~---------~--~----~------------~-------~--~----~



Get dimension from R.attr in Java code

by Dianne Hackborn » Mon, 21 Sep 2009 03:22:24 GMT


 You need to use the Theme API to retrieve the values of attributes
associated with the theme.










-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Animated-Rotate

I did some digging in Android code, and saw the use of <animated-
rotate> in the indeterminate progress bar. after trying to create my
own drawable with this tag:

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/
android"
    android:drawable="@drawable/spinner_pia"
    android:pivotX="50%"
    android:pivotY="50%"
    android:framesCount="12"
    android:frameDuration="100" />

I get an error:
"No resource identifier found for attribute 'frameDuration' in package
'android'" - which means that frameDuration is a private attribute.
Is there a way to use this "animate-rotate" feature?

-- 

2. Not able list the files using java.io.File.listFiles()

Hello All,
   I trying to list the files/directories in File System. But i am not able
to list  them. I could list files and directories under "/", but i am not
able list the sub directories "/data/" etc.

My code is...

private void fileListing(final File aDirectory){
        if (aDirectory.isDirectory()){
            File[] files = aDirectory.listFiles());  // For non-root
directories, files object array is always null
            if ( files != null) {
             for (File file : files){
                    //file.getPath()
                }
            }
        }
    }



.............

fileListing(new File("/"));  // Here i am able list the files.

fileListing(new File("/system/"));  // Here i am not able list files

Help me in resolving this.


Regards,
VIn

-- 

3. (WTA) Default Internet Browser Galaxy Tab.. Tidak bisa Jalan

4. VPN Client to connect to Cisco IPSec

5. Hardware opengles not working [libhgl.so required?]

6. Paging user ZTE blade

7. Samdroid [AOSP] v8.3 Froyo for Spica