我有一个需要用扫描仪扫描条形码的要求。扫描条形码后,我得到一个13位数的唯一条形码编号。
在Android中有没有可能找到用户输入的位置?它是来自条形码扫描仪还是软键盘?
发布于 2016-01-08 00:00:45
试着使用
int iean=0;
......
inputEan = (EditText) findViewById(R.id.inputEan);
inputEan.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
iean=0;
}
}
});
inputEan.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
iean=s.length();
//if iean == 0 it's scanner
//if iean == 13 it's keyboard
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});https://stackoverflow.com/questions/34018230
复制相似问题