Domanda

How one can disable addTextChangedListener on EditText?

Scenario:-

I've Four EditText which used to enter values on which arithmetic operations are done.

In Hand of % - Deducted Amount = Amount

In Hand % Deducted Amount are Editable and addTextChangedListener is applied.

Amount : Non Editable

In Hand % Deducted Amount have impact on each other.

Impacts:

If In Hand % changes :: Deducted Amount

Problem Area:

If Deducted Amount changes :: % according to In Hand

But as I've already applied addTextChangedListener on % which gives psuedo compound action.

È stato utile?

Soluzione

How about something like this:

    ...
    boolean changeDeductedAmount = true;
    ...
    //in InHand textChangeListener
    changeDeductedAmount = false;
    editTextDeductedAmount.setText(value);

    //in DeductedAmount textChangeListener
    if (changeDeductedAmount){
       //your code here if user edited text
    } else {
       //edit text was edited by your code, reset flag
       changeDeductedAmount = true;
    }

then do this for each pair of Edit text's that can change DeductedAmount

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top