I have an EditText. I want this edittext to always be in focus and writeable. How can I do this without touching it every time? Because barcode scanner machine sends data successive to this app.
anasayfa_barkod.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) &&
(i == KeyEvent.KEYCODE_ENTER)) {
adapter.clear();
adapter.notifyDataSetChanged();
geciciListeyeEkle();
listeyiYukle();
adapter.notifyDataSetChanged();
tutarYazdir();
if(anasayfa_verilenUcret.getText().length()>0){
try{
String ucret=anasayfa_verilenUcret.toString();
String paraustu=String.valueOf(Double.parseDouble(ucret)-gelenSatis);
anasayfa_paraustu.setText(paraustu);
}catch (NumberFormatException e){
e.printStackTrace();
}
}
anasayfa_barkod.requestFocus(); //not working
return true;
}
return false;
}
});
I tried a lot of method.but all of them is not working. I can set the keyboard is visible but cursor not on edittext.