Android LayoutFlater无法参照类对布局进行充气
我试图膨胀包含类的布局。 我使用以下命令创建充气机实例:Android LayoutFlater无法参照类对布局进行充气,android,Android,我试图膨胀包含类的布局。 我使用以下命令创建充气机实例: LayoutInflater inflate =(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mRelLayout = (RelativeLayout) inflate.inflate( R.layout.app_layout, null); 我的app_layout.xml布局
LayoutInflater inflate =(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mRelLayout = (RelativeLayout) inflate.inflate(
R.layout.app_layout, null);
我的app_layout.xml布局是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:panel="http://schemas.android.com/apk/res/com.alpha"
android:id="@+id/layoutMain"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="top|right">
.
.
.
膨胀失败,出现异常:java.lang.RuntimeException:您的面板必须具有id属性为“R.id.panelHandle”的子视图
感谢您的帮助我已经尝试了以下代码,它工作得非常完美,请提供完整的源代码,以便我能够识别错误 Test.java
LayoutInflater inflate =(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout mRelLayout = (RelativeLayout) inflate.inflate(
R.layout.app_layout, null);
app_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:panel="http://schemas.android.com/apk/res/com.alpha"
android:id="@+id/layoutMain"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="top|right" />
您是否尝试删除xmlns:panel=http://schemas.android.com/apk/res/com.alpha?
你能发布整个布局吗?我认为这行没有错误。我看不到有关panelHandle控件的代码。你能给我发一份日志吗?