1

ok i have several devices for emulating purposes, however this error only occurs at my galaxy s3 with android 4.3 i have no clue whats wrong with layout inflator when fetching contacts + numbers to the app.

FATAL EXCEPTION: Thread-27100
android.view.InflateException: Binary XML file line #38: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.ct.testapp.FindFriends$2.run(FindFriends.java:136)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 10 more
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:197)
at android.os.Handler.<init>(Handler.java:111)
at android.widget.Editor$UserDictionaryListener.<init>(Editor.java:6137)
at android.widget.Editor.<init>(Editor.java:251)
at android.widget.TextView.createEditorIfNeeded(TextView.java:10203)
at android.widget.TextView.setTextIsSelectable(TextView.java:5701)
at android.widget.TextView.<init>(TextView.java:1389)
at android.widget.TextView.<init>(TextView.java:876)
... 13 more

can some1 help me out?

/e

here s the code fragment:

if(phoneNo != null){
//Create view if contact has phone number
final LayoutInflater vi = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout v2 = (FrameLayout)vi.inflate(R.layout.add_friend_button, null);
View view = vi.inflate(R.layout.friend, null);
v2.addView(view);
TextView name = (TextView)view.findViewById(R.id.name);
TextView distance = (TextView)view.findViewById(R.id.distance);
ImageView image = (ImageView) view.findViewById(R.id.image);
name.setText(contact);
distance.setText(phoneNo);

/e2 xml file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="2dp"
    android:paddingBottom="2dp">

<ImageView
    android:id="@+id/image"
    android:layout_marginLeft="15dp"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:contentDescription="friendImage" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="3dp">

    <TextView
        android:id="@+id/name"
        android:paddingLeft="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="@color/lightgrey"
        android:textIsSelectable="true"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/distance"
        android:paddingLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/white"
        android:textIsSelectable="true"
        android:textStyle="bold" />

</LinearLayout>

Rishi Paul
  • 936
  • 2
  • 8
  • 25

1 Answers1

0
 *ThreadUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
           FrameLayout v2 =     (FrameLayout)vi.inflate(R.layout.add_friend_button, null);
            }
        });*
  • Welcome to SO! Can you please be so kind to add some text explaining how your answer solves the question? It would be of great help for other readers. – Laur Ivan May 18 '16 at 19:54
  • In my case i was trying to inflate TextView in GL Thread. After moving inflate statement to main thread it was working fine for me. – shyamji May 22 '16 at 17:48