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. modify Contacts.apk for use with Softbank

Hi,

I currently living in Japan, and I own a HTC Magic. I'm currently
subscribed to Softbank and have no intention of moving to Docomo or
any other carriers.

I'd like to modify the Contacts.apk to allow me to send MMS to my
contact's email address instead of their phone number. The reason for
this is that in Japan, the only way to send a MMS to other carriers is
via email. However, the email addresses that the carriers provide
requires you to send the email through their gateway, and the only way
to do this is to send them as MMSes through the messaging app.

Currently, I am able to send/receive emails via the messaging app by
entering the email address manually. So I'm hoping to modify the
Contacts app to allow me to add a new action that will open up the
messaging app, convert the message to MMS automatically, and insert
the contact's email address as the recipient.

So I'm hoping someone can help me;
1. Add a new menu called "Send S!Mail" (that's what MMS is called
here) on the long-press menu and when viewing contact details
2. Start the messaging app when the user taps on the new menu
3. Automatically tell the messaging app that you want to send an MMS
and convert it accordingly (add a subject field, etc)
4. Add the contact's email address into the "To" field

I don't think it's too difficult to do this, but since I've very new
to Android development, I have no idea where to start. I'm currently
looking through the source for the Contacts app, and figuring out what
the variables mean.

By the way, my Magic is on Android 1.6 (Donut) and my devkit is on a
Linux (Ubuntu) platform, also compiled for 1.6 Donut and the HTC
Sapphire (Magic).

Thanks a lot.

-- 

2. HTC Hero Stocks Widget Scrolling Ticker functionality

I have an HTC Hero from Sprint in the US and was curious about the how
the Stocks HTC widget scrolls text like a ticker. It is only the 4x1
sized widget that scrolls quotes. As far as I know, homescreen widgets
can only use RemoteViews for the layout, which is limited to the
following layouts and widgets (from
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout):

    * AbsoluteLayout
    * FrameLayout
    * LinearLayout
    * RelativeLayout
    * AnalogClock
    * Button
    * Chronometer
    * ImageButton
    * ImageView
    * ProgressBar
    * TextView
      Descendants of these classes are not supported.

I know that this could be done in an app with android.widget.scroller,
but that can't be used in a homescreen widget. Would this
functionality be specific to the Sense UI homescreen capabilities? I
guess, my main question is if this can be replicated for a standard
Android widget and if so how.

-- 

3. How to Convert 1.5 project to 2.0

4. LayerBase::drawWithOpenGL()

5. From cupcake to Eclair?

6. Kernel panic after clicking on the browser button

7. eclair's libgcc.a