Code example for Button

Methods: requestFocus

0
 
    // Test that a posted requestFocus works. 
    @LargeTest 
    public void testPostedRequestFocus() throws Exception { 
        mHandler.post(new Runnable() { public void run() {
            mBottomLeftButton.requestFocus();
        }}); 
        synchronized(this) {
            try { 
                wait(500);
            } catch (InterruptedException e) {
                // Don't care. 
            } 
        } 
        assertTrue("Focus should move to bottom left", mBottomLeftButton.hasFocus());
    } 
 
    // Test that a requestFocus from the wrong thread fails. 
    @MediumTest 
    public void testWrongThreadRequestFocusFails() throws Exception { 
        try {