Note that there are some explanatory texts on larger screens.

plurals
  1. POEdit Text Is not taking input at first Click in android
    primarykey
    data
    text
    <p>I am creating an application in which i want that user can enter the IP address at run time. In which i designed 4 edit Text where user can enter the IP address. I Created the XML for it. Now i created a custom class which extends TextWatcher to set addTextChangedListener for the EditText.</p> <pre><code> ipSlotFirst=(EditText)ipSettings.findViewById(R.id.ip_slot1); ipSlotFirst.setFilters(FilterArray); CustomOnTextChangeListener slot1=new CustomOnTextChangeListener(ipSlotFirst); ipSlotFirst.addTextChangedListener(slot1); ipSlotSecond=(EditText)ipSettings.findViewById(R.id.ip_slot2); ipSlotSecond.setFilters(FilterArray); CustomOnTextChangeListener slot2=new CustomOnTextChangeListener(ipSlotSecond); ipSlotSecond.addTextChangedListener(slot2); ipSlotThird=(EditText)ipSettings.findViewById(R.id.ip_slot3); ipSlotThird.setFilters(FilterArray); CustomOnTextChangeListener slot3=new CustomOnTextChangeListener(ipSlotThird); ipSlotThird.addTextChangedListener(slot3); ipSlotFourth=(EditText)ipSettings.findViewById(R.id.ip_slot4); ipSlotFourth.setFilters(FilterArray); CustomOnTextChangeListener slot4=new CustomOnTextChangeListener(ipSlotFourth); ipSlotFourth.addTextChangedListener(slot4); </code></pre> <p>Now i want when user enter three digit in one EditText it will automatically shift to the next Edit Text and when user deleting the content of the editText and focus shift to the previous Edit Text once the content of the Edit Text become empty.And i did it with a customOnTextChangeListener class.</p> <pre><code> class CustomOnTextChangeListener implements TextWatcher{ /** The m focused view. */ EditText mFocusedView; /** * Instantiates a new custom on text change listener. * * @param pFocusedView the focused view */ public CustomOnTextChangeListener(EditText pFocusedView){ mFocusedView = pFocusedView; } @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(mFocusedView.equals(ipSlotFirst)){ if(s.length()&gt;=3){ ipSlotSecond.requestFocus(); } }else if(mFocusedView.equals(ipSlotSecond)){ if(s.length()&gt;=3){ ipSlotThird.requestFocus(); }else if(s.length()==0){ ipSlotFirst.requestFocus(); } } else if(mFocusedView.equals(ipSlotThird)){ if(s.length()&gt;=3){ ipSlotFourth.requestFocus(); }else if(s.length()==0){ ipSlotSecond.requestFocus(); } }else if(mFocusedView.equals(ipSlotFourth)){ if(s.length()&gt;=3){ portNumber.requestFocus(); }else if(s.length()==0){ ipSlotThird.requestFocus(); } } } } </code></pre> <p>Everything is working fine. But I am facing a problem when i entered the ip like this 192 in first Edit Text then it shift automatically to second Edit Text and then i entered 10 then click on third Edit Text then click on a Number then first time Edit Text is not taking the Input.</p> <p>Kindly Help In this regards.</p> <p>Best Regards </p> <p>Deepak Goel</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload