我正在使用Dpad键监听器,它的工作正常,向上,向右,向左和向下键,但它不适用于Dpad中心或输入密钥在这里是我的代码。
public boolean onKeyDown(int keyCode, KeyEvent event) {
View v = getSaveView();
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
Toast.makeText(this, "its working", Toast.LENGTH_LONG).show();
//View c = getSaveView();
if(v.getId()==1){
Intent i =new Intent(HomeScreen.this,MainActivity.class);
startActivity(i);
}
break;
我在哪里做错了?