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. Lost focus on soft keyboard

Hi,

I implemented a custom preference screen on which I have an EditText
control. The problem I have is when the user clicks on the EditText
control to enter data, the soft keyboard pops-up and the EditText
loses the focus which makes it impossible to enter data.
What do I do wrong?

Thanks,
Yossi
--~--~---------~--~----~------------~-------~--~----~

2. Does anyone do XPath on Android?

I am trying to set up XML parsing using JDOM/Jaxen, but as soon as I
call

            XPath.setXPathClass(org.jaxen.jdom.JDOMXPath.class);

Android throws a "VerifyError" on that JDOMXPath class.

Any idea what is causing this? Does anyone do XPath on Android?

Cheers,
Matthias
--~--~---------~--~----~------------~-------~--~----~

3. Browser specs

4. Focus algorithm's default logic

5. Debit Cards Invalid on Android Market.

6. EditText with multiple listners

7. help: button.setBackgroundColor