[英]Caused by: java.lang.ClassNotFoundException with MaterialList
我遇到以下錯誤Caused by: java.lang.ClassNotFoundException: Didn't find class "com.dexafree.materiallistviewexample.view.MaterialListView"
運行我的應用程序時Caused by: java.lang.ClassNotFoundException: Didn't find class "com.dexafree.materiallistviewexample.view.MaterialListView"
錯誤。 我正在使用這個庫https://github.com/dexafree/MaterialList 。 這是我的代碼。 我想確定我在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'
}
}
歡迎使用StackOverflow,在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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.