Why does getPadding() of NinePatchDrawable throw a NullPointerException?

by Romain Guy » Tue, 13 Oct 2009 06:02:16 GMT


Sponsored Links
 NinePatchDrawable tagBalloon9pDrawable = new NinePatchDrawable(tagBalloon9p);

this creates a NinePatchDrawable with a null padding. That's why you
get an NPE. You need to specify the padding.






-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~



Why does getPadding() of NinePatchDrawable throw a NullPointerException?

by Romain Guy » Tue, 13 Oct 2009 06:02:56 GMT


 BTW, why are you creating the NinePatchDrawable yourself if you are
creating it from a resource anyway?







-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. InstrumentationTestCase.sendKeys() fails on headless emulators

Hi,

before reporting this as a bug, I thought I'd ask here (I also posted
on stackoverflow with no reply so far, but the Google developers don't
seem to be actively posting there anyway --
http://stackoverflow.com/questions/3214531/how-to-send-key-events-to-a-headless-emulator-in-an-instrumentation-test).

So the problem is:
We run a build server in our company on a headless Linux, so we have
to start the emulator with the -no-window flag when running the
instrumentation tests. When this flag is set, however, the
InstrumentationTestCase.sendKeys() method fails -- not with an
exception, but there is an obscure message in the device log:

Permission denied: injecting key event from pid 646 uid 10026 to
window Window{43d55100 paused=false} owned by uid 1000

this works fine on a "normal" emulator which does have a window.

We already tried fumbling with the INJECT_EVENTS permission, process
affinity and sharedUserId, but nothing works.

This basically makes our test suite useless on a build server, which
are typically headless. Is this a bug or are we missing something?

Thanks,
Matthias

-- 

2. Adding a tabhost in viewflipper

Hi,

I am new to this platform and already starting to love it. I am work
on a UI for a project which uses the tabhost to display two separate
activities using a TabActivity class. This works ok.

Now i would like to add a viewflipper to the equation. I am trying to
add the tabhost widget to the viewflipper using the addView() method.
Eg:
        public class Main extends TabActivity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                TabHost host = getTabHost();
                
host.addTab(host.newTabSpec("one").setIndicator("First").setContent(
                                new Intent(this, First.class)));
                host.addTab(host.newTabSpec("two").setIndicator("Second")
                                .setContent(new Intent(this, Second.class)));

               Button btn1 = new Button(this);
               btn1.setText("Notin' still dey happen");

               flipper = new ViewFlipper(this);
               flipper.addView(host);
               flipper.addView(btn1);

               setContentView(flipper);
        }

}

The main motive is to an application with two activities all tabbed.
The viewflipper will then flip between these two activities. I am
thinking an alternative will be to use xml layout to hold the tabhost
and just include it in the view.
I am avoiding it for now because that would mean me writing the codes
for the two classes again.

To round all this up, is there a way to include a tabhost in a
viewflipper.

Thanks,
New Guy

-- 

3. integrating skyhook in android application

4. About NexusOne Android2.1 contacts problem

5. statelistdrawable in xml

6. switch soundtracks of an mp4 file

7. Access to AT command interface of GSM radio