工作,我有onkeylistener事件的一個問題,我的代碼是這樣的onkeylistener不上的ImageButton
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.pnt_articulo);
imbAgregarArt = (ImageButton)findViewById(R.id.imbAgregarArt);
imbAgregarArt.setOnKeyListener(key);
}
OnKeyListener key = new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN) {
Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
};
我使用調試停在吐司線不進入
請幫助
使用'OnClickListener' –
感謝薩米爾,我錯了,我嘗試做的是聽點擊按鈕 – japuentem