How to catch event from the virtual keyboard ?

by Dianne Hackborn » Thu, 30 Jul 2009 21:43:11 GMT


Sponsored Links
 Either set the window flag to have your IME's window consume all touch
events, or make it larger so the user hits it.  Note that there is no way to
be able to receive touch events there and selectively decide whether they go
to the underlying application, it is either all or nothing.







-- 
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. Animation not start immediately when the target view is out of window

Hi.
When I apply some animation to the view, which is out of window, the
animation not start immediately.
And then, I scroll the screen to show the animation target view, the
animation will start.
I hope to the animation will start immediately when it apply. Any
ideas?
Bellow is sample code. Thank you.

public class AnimationValidationActivity extends Activity {
    private ViewSwitcher _viewSwitcher;
    private Button _button;

    /**
     * utility method for animation
     */
    private Animation buildTranslateAnimation( float fromXDelta ,
float toXDelta , float fromYDelta , float toYDelta ) {
        Animation ret = new TranslateAnimation( fromXDelta ,
toXDelta , fromYDelta , toYDelta );
        ret.setDuration( 1000 );

        return ret;
    }

    /**
     * build view in place of layout.xml
     */
    private View buildView() {
        ScrollView ret = new ScrollView( this );
        ret.setLayoutParams( new
LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT ,
                LinearLayout.LayoutParams.WRAP_CONTENT ) );

        LinearLayout parent = new LinearLayout( this );
        parent.setLayoutParams( new
LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT ,
                LinearLayout.LayoutParams.WRAP_CONTENT ) );
        parent.setOrientation( LinearLayout.VERTICAL );
        ret.addView( parent );

        _viewSwitcher = new ViewSwitcher( this );
        _viewSwitcher.setLayoutParams( new
LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT ,
100 ) );
        parent.addView( _viewSwitcher );

        View spacer = new View( this );
        spacer.setLayoutParams( new
LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT ,
getWindow()
                .getWindowManager().getDefaultDisplay().getHeight() ) );
        parent.addView( spacer );

        _button = new Button( this );
        _button.setText( "button" );
        parent.addView( _button );

        return ret;
    }

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

        _viewSwitcher.setFactory( new ViewSwitcher.ViewFactory() {
            @Override
            public View makeView() {
                TextView view = new
TextView( AnimationValidationActivity.this );
                view.setLayoutParams( new
ViewSwitcher.LayoutParams( ViewSwitcher.LayoutParams.FILL_PARENT ,
                        ViewSwitcher.LayoutParams.FILL_PARENT ) );
                view.setBackgroundColor( 0xffffffff );

                view.setText( "foobar" );

                return view;
            }
        } );

        _button.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick( View v ) {
 
_viewSwitcher.setInAnimation( buildTranslateAnimation( _viewSwitcher.getWidth() 
,
0 , 0 , 0 ) );
 
_viewSwitcher.setOutAnimation( buildTranslateAnimation( 0 , -
_viewSwitcher.getWidth() , 0 , 0 ) );

                int color = new Random().nextInt();
 
_viewSwitcher.getNextView().setBackgroundColor( 0xff000000 | color &
0xffffff );
                _viewSwitcher.showNext();
            }
        } );
    }
}

-- 

2. Will there be 2nd round of Device Seeding Program?

I hope they can re-launch the program. I just missed the previous one!

-- 

3. why is my depth test not working on android

4. Age of Heroes Online 锌芯写 And roid

5. How to measure width of indicator in ExpandableListView?

6. Synchronization

7. Dynamically obtaining several instance of a view item defined in layout/xml file