在使用LayoutInflater对Fragment中的布局进行膨胀时,我收到此异常:
./res/layout/locations_list.xml line #-1 (sorry, not yet implemented): Error inflating class com.costum.android.widget.LoadMoreListView
Run Code Online (Sandbox Code Playgroud)
我发现在充气自定义布局时会发生这种情况
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.locations_list, container, false);
}
Run Code Online (Sandbox Code Playgroud)
编辑这是locations_list.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical" >
<com.costum.android.widget.LoadMoreListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
任何其他布局充气机工作,如在此测试中:
@Test
public void testInflator() {
ActivityController<SherlockFragmentActivity> activityController = CustomTestRunner
.startActivity();
SherlockFragmentActivity activity = activityController.get();
LayoutInflater from = LayoutInflater.from(activity);
View view = from
.inflate(com.twisper.R.layout.locations_list_item, null);
assertNotNull(view);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用带有2.2-SNAPSHOT的Robolectric,现在我的问题是如何解决这个问题或者如何实现缺少的功能,robolectric文档非常稀疏,因此我很难找到任何起点.
全栈跟踪
android.view.InflateException: XML file ./res/layout/locations_list.xml …Run Code Online (Sandbox Code Playgroud)