This also for changing alternate editText value after change TextWatcher in Andorid.

Or This Error:- java.lang.stackoverflowerror stack size 8mb edittext aftertextchanged.

try this :-

public class MainActivity extends AppCompatActivity 
implements TextWatcher{

   EditText editText1, editText2;
   @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       editText1 = findViewById(R.id.editText1);
       editText2 = findViewById(R.id.editText2);

       editText1.addTextChangedListener(this);
       editText2.addTextChangedListener(this);

      }

    @Override
    public void beforeTextChanged(CharSequence s, int start, 
           int 
           count, int after) {

    }

   @Override
   public void onTextChanged(CharSequence s, int start, int 
           before, int count) {

   }

  @Override
  public void afterTextChanged(Editable s) {

      if (getCurrentFocus() == editText1) {
         // is only executed if the EditText was directly 
            changed by the user.
          Log.e("check","getCurrentFocus() == editText1");

          editText2.removeTextChangedListener(this);

          editText2.setText(String.valueOf(s));

          editText2.addTextChangedListener(this);

       //            editText1.clearFocus();
      }

      if (getCurrentFocus() == editText2) {
          // is only executed if the EditText was directly 
             changed by the user
          Log.e("check","getCurrentFocus() == editText2");

          editText1.removeTextChangedListener(this);

          editText1.setText(String.valueOf(s));

          editText1.addTextChangedListener(this);

        //            editText2.clearFocus();
        }


   }

}

Comments

Popular posts from this blog

Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation' and 'androidTestApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Get Two digit after decimal point in Android or Java

Error:java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:240) at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215) at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:143) at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:78) at com.google.android.material.chip.ChipDrawable.loadFromAttributes(ChipDrawable.java:359) at com.google.android.material.chip.ChipDrawable.createFromAttributes(ChipDrawable.java:292) at com.google.android.material.chip.Chip.(Chip.java:193) at com.google.android.material.chip.Chip.(Chip.java:186) at com.google.android.material.chip.Chip.(Chip.java:182) at com.demo.nspl.restaurantlite.Navigation_Drawer.SalesFragment.getFilterChip(SalesFragment.java:158) at com.demo.nspl.restaurantlite.Navigation_Drawer.SalesFragment.lambda$onCreateView$0(SalesFragment.java:71) at com.demo.nspl.restaurantlite.Navigation_Drawer.-$$Lambda$SalesFragment$KCm-iiczjdYbpiNmaNw12gtFOoQ.onClick(lambda) at android.view.View.performClick(View.java:5268) at android.view.View$PerformClick.run(View.java:21550) at android.os.Handler.handleCallback(Handler.java:822) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5811) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)