Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一台配备硬件条码扫描仪的摩托罗拉 TC55。我想做的是听我的应用程序中按下的那个按钮。我已经用谷歌搜索并查看了 SO 没有任何运气。有人可以指出我的资源,或者建议我如何开始吗?
在摩托罗拉 TC55 上,硬件扫描按钮默认映射到键“BUTTON_L1”,因此您会听到如下所示的内容。
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BUTTON_L1 { //Do something scanner was pressed. } }
您可以通过 Settings->Programmable Keys 看到它映射到的键
当我使用 Actionbarsherlock
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: this.finish();