java.lang.NoClassDefFoundError: com.app.VideoAlbumCustomBaseAdapter$ViewHolder
java.lang.NoClassDefFoundError: com.app.VideoAlbumCustomBaseAdapter$ViewHolder
出现错误java.lang.NoClassDefFoundError
,可能是什么原因? ViewHolder 已经写在同一个 java 文件中,
VideoAlbumCustomBaseAdapter.JAVA
public class VideoAlbumCustomBaseAdapter extends BaseAdapter {
Context context;
List<VideoAlbumRowItem> rowItems;
public VideoAlbumCustomBaseAdapter(Context context, List<VideoAlbumRowItem> items) {
this.context = context;
this.rowItems = items;
}
private class ViewHolder {
ImageView imageView;
TextView txtNothing;
TextView txtSubtitle;
TextView txtTitle;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.videoalbum_item,null);//ecology_list_item, null);
holder = new ViewHolder();
holder.txtTitle = (TextView) convertView.findViewById(R.id.video_text);
holder.txtSubtitle = (TextView)convertView.findViewById(R.id.txtSubtitle);
holder.txtNothing = (TextView) convertView.findViewById(R.id.textView8);
holder.imageView = (ImageView) convertView.findViewById(R.id.video_list_img);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
VideoAlbumRowItem rowItem = (VideoAlbumRowItem) getItem(position);
holder.txtTitle.setText(rowItem.getTitle());
holder.txtSubtitle.setText(rowItem.getSubtitle());
holder.txtNothing.setText(rowItem.getNothing());
holder.imageView.setImageResource(rowItem.getImageId());
return convertView;
}
@Override
public int getCount() {
return rowItems.size();
}
@Override
public Object getItem(int position) {
return rowItems.get(position);
}
@Override
public long getItemId(int position) {
return rowItems.indexOf(getItem(position));
}
}
错误日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app, PID: 4164
java.lang.NoClassDefFoundError: com.app.VideoAlbumCustomBaseAdapter$ViewHolder
at com.app.VideoAlbumCustomBaseAdapter.getView(VideoAlbumCustomBaseAdapter.java:39)
at android.widget.AbsListView.obtainView(AbsListView.java:2255)
at android.widget.ListView.makeAndAddView(ListView.java:1790)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillFromTop(ListView.java:752)
at android.widget.ListView.layoutChildren(ListView.java:1630)
at android.widget.AbsListView.onLayout(AbsListView.java:2087)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1740)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
尝试制作 ViewHolder public
and/or static
而不是 private
.
出现错误java.lang.NoClassDefFoundError
,可能是什么原因? ViewHolder 已经写在同一个 java 文件中,
VideoAlbumCustomBaseAdapter.JAVA
public class VideoAlbumCustomBaseAdapter extends BaseAdapter {
Context context;
List<VideoAlbumRowItem> rowItems;
public VideoAlbumCustomBaseAdapter(Context context, List<VideoAlbumRowItem> items) {
this.context = context;
this.rowItems = items;
}
private class ViewHolder {
ImageView imageView;
TextView txtNothing;
TextView txtSubtitle;
TextView txtTitle;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.videoalbum_item,null);//ecology_list_item, null);
holder = new ViewHolder();
holder.txtTitle = (TextView) convertView.findViewById(R.id.video_text);
holder.txtSubtitle = (TextView)convertView.findViewById(R.id.txtSubtitle);
holder.txtNothing = (TextView) convertView.findViewById(R.id.textView8);
holder.imageView = (ImageView) convertView.findViewById(R.id.video_list_img);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
VideoAlbumRowItem rowItem = (VideoAlbumRowItem) getItem(position);
holder.txtTitle.setText(rowItem.getTitle());
holder.txtSubtitle.setText(rowItem.getSubtitle());
holder.txtNothing.setText(rowItem.getNothing());
holder.imageView.setImageResource(rowItem.getImageId());
return convertView;
}
@Override
public int getCount() {
return rowItems.size();
}
@Override
public Object getItem(int position) {
return rowItems.get(position);
}
@Override
public long getItemId(int position) {
return rowItems.indexOf(getItem(position));
}
}
错误日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app, PID: 4164
java.lang.NoClassDefFoundError: com.app.VideoAlbumCustomBaseAdapter$ViewHolder
at com.app.VideoAlbumCustomBaseAdapter.getView(VideoAlbumCustomBaseAdapter.java:39)
at android.widget.AbsListView.obtainView(AbsListView.java:2255)
at android.widget.ListView.makeAndAddView(ListView.java:1790)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillFromTop(ListView.java:752)
at android.widget.ListView.layoutChildren(ListView.java:1630)
at android.widget.AbsListView.onLayout(AbsListView.java:2087)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1740)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
尝试制作 ViewHolder public
and/or static
而不是 private
.