-2

I have used simple Edit Text in my activity just like below. I have tried different solutions from stack and other resources but it does't solve my issue.

<EditText
            android:id="@+id/edtRemarks"
            android:layout_width="match_parent"
            android:layout_height="80dip"
            android:gravity="left|top"
            android:hint="Enter comments1"
            android:padding="5dp"
            android:textSize="16sp"
            android:textStyle="normal" />

On long press below error occurs

android.view.InflateException: Binary XML file line #17: Error inflating class TextView
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
     at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2928)
     at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2233)
     at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
     at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
     at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3302)
     at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3536)
     at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3780)
     at android.widget.Editor.performLongClick(Editor.java:866)
     at android.widget.TextView.performLongClick(TextView.java:8660)
     at android.view.View$CheckForLongPress.run(View.java:19723)
     at android.os.Handler.handleCallback(Handler.java:739)
     at android.os.Handler.dispatchMessage(Handler.java:95)
     at android.os.Looper.loop(Looper.java:135)
     at android.app.ActivityThread.main(ActivityThread.java:5221)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1552
     at android.content.res.StringBlock.get(StringBlock.java:65)
     at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
     at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:967)
     at android.content.res.TypedArray.getString(TypedArray.java:176)
     at android.widget.TextView.<init>(TextView.java:1011)
     at android.widget.TextView.<init>(TextView.java:629)
     at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:48)
     at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:44)
     at android.support.v7.internal.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
     at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:912)
     at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:966)
     at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
     at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2928) 
     at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2233) 
     at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901) 
     at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901) 
     at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3302) 
     at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3536) 
     at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3780) 
     at android.widget.Editor.performLongClick(Editor.java:866) 
     at android.widget.TextView.performLongClick(TextView.java:8660) 
     at android.view.View$CheckForLongPress.run(View.java:19723) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5221) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

Any idea why this is happening only in 5.0.1 and 5.0.2? it's working fine in <= KITKAT devices.

EDITED:

i found solution here, remove font family from app. but i have used like below. is there way to remove font for edittext only? remain app work with font?

style.xml in values-v21 folder

<style name="AppTheme" parent="AppTheme.Bash">
        <item name="homeAsUpIndicator">@null</item>
        <item name="android:homeAsUpIndicator">@null</item>
        <item name="actionBarStyle">@style/CustomActionBarStyle</item>
        <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
        <item name="android:fontFamily">sans-serif-light</item>
    </style>
Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • 1
    Possible duplicate of [Android EditText on longPress: ArrayIndexOutOfBoundsException: length=15; index=491](http://stackoverflow.com/questions/16444061/android-edittext-on-longpress-arrayindexoutofboundsexception-length-15-index) – Rami Oct 12 '15 at 12:52

2 Answers2

2

Deletes the next line:

<item name="android:fontFamily">sans-serif-light</item>

apparently it does not support Change language in some versions

Oscar Duarte
  • 521
  • 5
  • 5
0

Fixed it

Delete this line from the theme - styles.xml. Problem may occur due to this font item in the App theme or activity theme or in element theme.

<item name="android:fontFamily"> some fonts </item>

This works for me and get free from Long press crash in lower android versions... Works for both EditText and Material TextInputEditText.