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. Newbie looking to buy a handset

Hey all,

I'm new to developing apps for Android, and am planning to purchase a
handset in the coming few months.

I live in India and plan on having my sister buy one in the US and
send it to me (there hardly are any Android handsets over here, the
latest being the Motorola Milestone). I wanted to know if I'd face
difficulties getting the Android updates or downloading apps. I'd be
purchasing a unlocked handset, so it's not like I'm messing with the
system.

Also, I'm planning on buying the Google N1, but I've heard some users
have faced problems with the 3G. Are there any particular reasons for
the problems, ie, is it the network or the handset's fault?



with best regards,


Raveesh

-- 

2. Intisari untuk id-android@googlegroups.com - 25 Pesan pada 16 Topik

sumpeh gue bingung sama reply tipe gini
digest tapi bingung sebenernya ngomongin apaan.


2010/5/28 zee see <motwo...@gmail.com>

> 

3. Passing surfaces between processes

4. Deploy my app

5. What would cause an activity's private field to be cleared after onActivityResult?

6. debugging the (suddenly) crippling slowness of the emulator

7. A calendar ui component / widget