我想 inflate 包含类的布局。用下面的代码创建了 inflater 实例
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">
然而Inflation 失败,出现了异常: java.lang.RuntimeException
,说我的面板必须有有一个id属性是'R.id.panelHandle'
的子视图。
这是怎么回事呢?