I get an IndexOutOfBoundsException on Samsung Galaxy S5 and 3 and 4. It does not reference my code. Has anyone come across this? I could not find anything here.
This seems to happen sometimes when you try to long click on an EditText to paste something.
Edit:
I use a simple EditText field (not in ListView or Spinner). There is a hint of 28 characters. I switch focus several times through clearFocus , and I use setOnEditorActionListener and setOnFocusChangeListener , which control setOnFocusChangeListener fragment attaches to the Activity.
Edit # 2:
I was able to successfully play it, trying to click on EditText for a long time to try to insert something. This only happens when there is text in the EditText, and for a long time I click on the RIGHT of the text, and not on it. In addition, EditText should not have focus.
Any possible solution by creating a custom EditText and overriding some methods?
java.lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 0 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1024) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:594) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:590) at android.text.Selection.setSelection(Selection.java:116) at android.text.Selection.setSelection(Selection.java:127) at android.widget.Editor.performLongClick(Editor.java:1008) at android.widget.TextView.performLongClick(TextView.java:10637) at android.view.View$CheckForLongPress.run(View.java:19482) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5678) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at dalvik.system.NativeStart.main(Native Method)
the code:
editText.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { String searchText = v.getText().toString(); FragmentSearchList fragmentSearchList = (FragmentSearchList) getChildFragmentManager().findFragmentByTag(FRAGMENT_SEARCH_LIST_TAG); if(fragmentSearchList != null){ fragmentSearchList.executeSearch(searchText); } return true; } }); editText.setOnFocusChangeListener(new OnFocusChangeListener(){ @Override public void onFocusChange(View view, boolean hasFocus) { if(hasFocus){ FragmentManager fragmentManager = getChildFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(FRAGMENT_SEARCH_LIST_TAG); if(fragment == null){ editText.setText(null); FragmentSearchList fragmentSearchList = FragmentSearchList.newInstance(); FragmentTransaction fragmentSearchListTransaction = fragmentManager.beginTransaction(); fragmentSearchListTransaction.add(R.id.viewGroupFragmentSearchListContainer, fragmentSearchList, FRAGMENT_SEARCH_LIST_TAG); fragmentSearchListTransaction.addToBackStack(null); fragmentSearchListTransaction.commit(); } } else{ if(!isRemovingOrPartOfRemovalChain()){ editText.setText(mAreaName); getChildFragmentManager().popBackStack(); } } } }); public boolean isRemovingOrPartOfRemovalChain(){ if(isRemoving()){ return true; } Fragment fragment = this.getParentFragment(); if(fragment != null){ if(((MainFragment)fragment).isRemovingOrPartOfRemovalChain()){ return true; } else{ return false; } } else{ return(this.getActivity().isFinishing()); } }
android indexoutofboundsexception samsung-mobile
ono
source share