扫描头开启,并发送回车
txtUsername.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
if(arg2.getKeyCode()==KeyEvent.KEYCODE_ENTER){
// TODO Auto-generated method stub
txtPassword.setText("xxxx");
return true;
}
return false;
}
});
<EditText
android:id="@+id/txtUsername"
android:imeOptions="actionDone"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >