好吧我有几个用于模拟目的的设备,但是这个错误只发生在我的带有android 4.3的galaxy s3上 在向应用程序提取联系人+号码时,我对布局充气器没有任何疑问。
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
可以帮助我吗?
/ E
这里是代码片段:
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文件
<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>
答案 0 :(得分:0)
*ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
FrameLayout v2 = (FrameLayout)vi.inflate(R.layout.add_friend_button, null);
}
});*