My basic code is works, but then i confuse about trigger, when edit some editText. When editText is edit or change..
my reference's :
My input type Xml is number, and i try it. other method is use ignore, and still got same result, stuck. number|textNoSuggestions
Compare to this, android edittext onchange listener my code still make in sense..
The strange result from this : Events of TextWatcher are being called twice
.
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(position).setEditTextValueCrt(holder.editTextCrt.getText().toString());
if (mToggle) {
if (mToggle2) {
Log.d(TAG, "onTextChanged: HIT KEY" + mToggle);
}
mToggle2 = !mToggle2;
}
mToggle = !mToggle;
}
The first code will only fires/trigger for 1 times, compare with 2nd codes will result multiple trigger at once :
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(position).setEditTextValueCrt(holder.editTextCrt.getText().toString());
if (mToggle) {
if (mToggle2) {
Log.d(TAG, "onTextChanged: HIT KEY" + mToggle);
try {
Integer val = Integer.valueOf(holder.editTextSeq.getText().toString());
if exist data previously, so never replace in seq only
}
catch (Exception e){
//get all data, if empty > set 1, else set : check all data, count data +1
List<Integer> listQtySeq;
listQtySeq = new ArrayList<Integer>();
for (int j = 0; j < CustomeAdapter.editModelArrayList.size(); j++){
String nilaiSeq = editModelArrayList.get(j).getEditTextValueSeq();
nilaiSeq = checkNull(nilaiSeq);
if (Integer.parseInt(nilaiSeq) > 0) {
listQtySeq.add(Integer.parseInt(nilaiSeq));
}
}
Log.d(TAG, "afterTextChanged: size llistq: "+listQtySeq.size());
if(listQtySeq.size()<1){
editModelArrayList.get(position).setEditTextValueSeq("1");
}
else{
Integer totSize = listQtySeq.size()+1;
Log.d(TAG, "afterTextChanged: size newZise: "+totSize.toString());
editModelArrayList.get(position).setEditTextValueSeq(totSize.toString());
}
Log.d(TAG, "onTextChanged: error ~" + e);
}
}
mToggle2 = !mToggle2;
}
mToggle = !mToggle;
}
I want to use that method to execute only once, with some customize code. My question is why my second code invoke multiple trigger, i didn't use loop, or else,,
Thanks for help.