zoumengdie wrote:
> Hi everyone!
> I want to attach a picture onto a button. Here is my code:
> ......
> Button button1 = (Button)findViewById(R.id.Button1);
> Drawable pic = new PaintDrawable().createFromPath("D:\\Android\
> \all.jpg");
> button1.setBackground(pic);
> ......
> There was no exception, but it doesn't work either! So how can I
> attach an existing picture onto a button?
> Any answer is appreciated!
There is no D: drive on a phone. All paths have to resolve within the
phone's filesystem.
If your goal is to embed some graphic from your development workstation
into your project, put it in res/drawable/ in your project and reference
it via the corresponding resource ID (R.drawable.whateveryoucalledit).
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training on the Ranch in September! http://www.bignerdranch.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---