原因:java.lang.ClassNotFoundException 与 MaterialList
Caused by: java.lang.ClassNotFoundException with MaterialList
我的应用程序 运行 出现 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.dexafree.materiallistviewexample.view.MaterialListView"
错误。我正在使用这个库 https://github.com/dexafree/MaterialList。这是我的代码。在 post 关于 Github 的问题之前,我想确定我没有做错什么。谢谢!
Fragment1.java:
public class FragmentTab1 extends ListFragment {
private Context mContext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmenttab1, null);
mContext = getActivity();
MaterialListView mListView = (MaterialListView) view.findViewById(R.id.material_listview);
SimpleCard card = new SmallImageCard(mContext);
card.setDescription("Description");
card.setTitle("Title");
card.setDrawable(R.drawable.ic_launcher);
mListView.add(card);
return view;
}
FragmentTab1.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<com.dexafree.materiallistviewexample.view.MaterialListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/material_listview"/>
</RelativeLayout>
build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile ('com.github.dexafree:materiallist:2.0.1') {
exclude group: 'com.nhaarman.listviewanimations'
}
}
欢迎使用 Whosebug,更改 FragmentTab1.xml
中的包:
来自 :
com.dexafree.materiallistviewexample.view.MaterialListView
至:
com.dexafree.materiallist.view.MaterialListView
FragmentTab1.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<com.dexafree.materiallist.view.MaterialListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/material_listview"/>
</RelativeLayout>
问题 1
检查 1MaterialListView` 的路径。看来你用错了路径。
问题2
将列表视图的 ID 更改为此
android:id="@android:id/list"
或扩展 Fragment
而不是 ListFragment
我的应用程序 运行 出现 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.dexafree.materiallistviewexample.view.MaterialListView"
错误。我正在使用这个库 https://github.com/dexafree/MaterialList。这是我的代码。在 post 关于 Github 的问题之前,我想确定我没有做错什么。谢谢!
Fragment1.java:
public class FragmentTab1 extends ListFragment {
private Context mContext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmenttab1, null);
mContext = getActivity();
MaterialListView mListView = (MaterialListView) view.findViewById(R.id.material_listview);
SimpleCard card = new SmallImageCard(mContext);
card.setDescription("Description");
card.setTitle("Title");
card.setDrawable(R.drawable.ic_launcher);
mListView.add(card);
return view;
}
FragmentTab1.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<com.dexafree.materiallistviewexample.view.MaterialListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/material_listview"/>
</RelativeLayout>
build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile ('com.github.dexafree:materiallist:2.0.1') {
exclude group: 'com.nhaarman.listviewanimations'
}
}
欢迎使用 Whosebug,更改 FragmentTab1.xml
中的包:
来自 :
com.dexafree.materiallistviewexample.view.MaterialListView
至:
com.dexafree.materiallist.view.MaterialListView
FragmentTab1.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<com.dexafree.materiallist.view.MaterialListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/material_listview"/>
</RelativeLayout>
问题 1
检查 1MaterialListView` 的路径。看来你用错了路径。
问题2
将列表视图的 ID 更改为此
android:id="@android:id/list"
或扩展 Fragment
而不是 ListFragment