我想在我的代码中指定在按下android键盘上的后退按钮后移动到特定活动。我怎样才能做到这一点?朋友帮助我。如何在按下android键盘后移动到特定活动(android)
现在我在朋友的帮助下找到了解决方案。
我找到了解决我的问题的方法。 onBackPressed()
在1.6版之后工作。对于以前的版本中,我们需要使用 public boolean onKeyDown(int keyCode, KeyEvent event)
方法
我给这解决的问题代码
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.CUR_DEVELOPMENT
&& keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0) {
// Take care of calling this method on earlier versions of
// the platform where it doesn't exist.
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
//@Override
public void onBackPressed() {
// This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the
// platform.
Intent i=new Intent(AgesWebViewIndex.this,TabCls.class);
i.putExtra("age", "agepage");
startActivity(i);
return;
}
感谢ü我FRND我希望这本书能解决我的概率现在我会尝试这 – 2010-07-29 06:40:37