Reputation: 151
Looking for help on this. I have 2 EditTexts on an activity. When user get to screen the first EditText has focus for input from a scanner. User scans barcode and program validates it is a good read by finding corresponding item from database. If finds the item I am trying to get the second EditText to have focus for the next scan.
I am new to java (VB windows developer) and struggling to accomplish this. No matter what I have tried everytime I scan the second barcode the first EditText gets what is scanned.
I am having hard time figuring out how to change the listener to be focused on Second EditText.
Can someone please explain how to change the focus to second EditText after a valid first scan.
public void listener() {
scanner.scannerListener = new ScannerListener() {
@Override
public void listener() {
sChecker = mEntryText.getText().toString();
if (sChecker.equals("")) ;
{
mScan = scanner.getScanResult();
Timber.d("The barcode is " + mScan);
if (!mScan.equals("")) {
int lmScan = mScan.length();
if (lmScan > 15) {
checkGs1Barcode();
}
String s = DatabaseMgr.VerifyItem(mScan);
if (s.length() > 1) {
if (s.equalsIgnoreCase("Unknown Item###")) {
Toast.makeText(getApplicationContext(), "Unknown Item", Toast.LENGTH_SHORT).show();
} else if (s.equalsIgnoreCase("Multiple Items###")) {
setupMultiItems(mScan);
} else {
String[] sArr = s.split("\\#");
String IsItem = sArr[0];
String IsItemDesc = sArr[1];
String isLevel = sArr[2];
String isLvlDesc = sArr[3];
Button ItemDescText = findViewById(R.id.btnDesc);
ItemDescText.setText(IsItemDesc);
TextView ItemUPCText = findViewById(R.id.editUPC);
ItemUPCText.setText(mScan);
Integer iQTY = ValidateQTYinArea(IsItem, "RTN", myArea, isLevel);
TextView mQty = findViewById(R.id.txtDetail);
String myResult = "RTN - " + myArea + " - " + isLvlDesc + " - " + iQTY;
mQty.setText(myResult);
mEntryText.setBackgroundColor(getResources().getColor(R.color.colorWhite));
mLoc.setBackgroundColor(getResources().getColor(R.color.colorYellow));
mLoc.requestFocus();
}
}
} else {
mLoc.setText(scanner.getScanResult());
}
}
}
};
}
the mLoc.setText line is not getting hit
Upvotes: 0
Views: 107
Reputation: 3869
So what you need to do is:
if (sChecker.equals("")){
mEditText1.setText("text to be set");
}else{
mEditText2.setText("text to be set");
}
Upvotes: 1