一对Android软键盘问题

这是一个转发,我为任何破坏的规则道歉,但我有几个关于Android手机软键盘的问题: 1)我有一个Android应用程序,有几个不同的视图(用户之间切换)。如何确定当前视图?我需要获取当前视图来执行隐藏虚拟键盘的代码。 2)如何检查当前是否正在显示虚拟键盘(这样我可以过滤各种硬键的动作)? 谢谢, R.     
已邀请:
1) 公共类ViewIdentification扩展了Activity实现OnFocusChangeListener {
EditText _edt1;
EditText _edt2;
EditText _edt3;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    _edt1 = (EditText)findViewById(R.id.EditText01);
    _edt1.setOnFocusChangeListener(ViewIdentification.this);
    _edt2 = (EditText)findViewById(R.id.EditText02);
    _edt2.setOnFocusChangeListener(ViewIdentification.this);
    _edt3 = (EditText)findViewById(R.id.EditText03);    
    _edt3.setOnFocusChangeListener(ViewIdentification.this);


}

@Override
public void onFocusChange(View v, boolean hasFocus) {
    // TODO Auto-generated method stub

       if(v == _edt1 && hasFocus == true){

        Toast.makeText(ViewIdentification.this, "The First EditText is focused now", Toast.LENGTH_LONG).show();

       }else if(v == _edt2 && hasFocus == true){

        Toast.makeText(ViewIdentification.this, "The Second EditText is focused now", Toast.LENGTH_LONG).show();

       }else if(v == _edt3 && hasFocus == true){

        Toast.makeText(ViewIdentification.this, "The Third EditText is focused now", Toast.LENGTH_LONG).show();

       }

}
} 注意:通过这种方式,我们可以了解哪个视图是关注的。 2) 这可以通过计算活动的大小(最后一个聚焦视图所在的位置)来完成。     

要回复问题请先登录注册