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. 鈽匴hat is the plan of the 2-way and video conference?

According to OpenCore 2.x , 2-way are release.
For video conference, I think it also need some more work:
1. Camera interface need update in every level.
2. Need a Andorid 2-way.
Who can tell us the schedule or plan about the video conference?
--~--~---------~--~----~------------~-------~--~----~

2. Android App.Theme

Hello,
how i place the title of my app in center?
and how i put a image as a title?

rgds
       Mr.No
--~--~---------~--~----~------------~-------~--~----~

3. can't read mp3 file from sdcard

4. How to stop Gallery scroll?

5. Viewing the Camera Preview frames .......

6. sensors HAL

7. How to get raw data decoded by MediaPlayer