【发布时间】:2015-11-14 13:22:55
【问题描述】:
我在尝试调用此方法时遇到以下异常。
MessageQueue 回调中的异常:handleReceiveCallback 08-21 00:12:43.454 10843-10843/common.barter.com.barterapp E/MessageQueue-JNI: android.view.InflateException: 二进制 XML 文件 第 2 行:错误膨胀类 在 android.view.LayoutInflater.createView(LayoutInflater.java:633) 在 com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 在 android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:482) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:414) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:365)
public class GlobalHome extends ActionBarActivity{
----------------------
----------------------
private void showLocationPopup() {
LayoutInflater inflater = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup_location,
(ViewGroup) findViewById(R.id.layout_location_popup));
PopupWindow pw = new PopupWindow(
layout,
100,
100,
true);
// The code below assumes that the root container has an id called 'main'
pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
}
}
布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/switch_thumb_material_light"
android:id="@+id/layout_location_popup"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Test Pop-Up"
/>
</LinearLayout>
【问题讨论】:
-
能否请您发布您要膨胀的布局文件?
-
@anytoe 更新了帖子。
-
如果我在没有错误的情况下更改颜色,我会在屏幕中间看到一个小弹出窗口,例如:android:background="#FFFFFF",所以也许你的问题应该是:为什么这种颜色不适用于弹出窗口?
-
感谢@anytoe,但我看不到内容(文本视图)。
-
请参阅下面的答案,如果它为您解决了问题,请接受
标签: android popupwindow inflate-exception