2013-07-12 83 views

回答

-1

這是這件事情,我發現here

@Override 
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
    final int proposedheight = MeasureSpec.getSize(heightMeasureSpec); 
    final int actualHeight = getHeight(); 

    if (actualHeight > proposedheight){ 
     // Keyboard is shown 
    } else { 
     // Keyboard is hidden 
    } 

    super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
} 

或者你可以使用從here方法:

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 


    // Checks whether a hardware keyboard is available 
    if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { 
     Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show(); 
    } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { 
     Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show(); 
    } 
} 
+1

這是JavaScript的? – falko

+0

它是java,當事件在那裏被捕獲時,那麼可以執行javascript塊。 – g00dy