问题描述:运行代码是报空指针错误,java.lang.NullPointerException,at Android.widget.ListView.setupChild

问题定位:listview控件报错,查找原因并没有问题,怀疑adapter设置item值时出错,检查代码,果然是这里报错

在设置完adapter的item值得时候,由于粗心,return convertView 时第一次返回成了  return null,导致了上述错误

 public class CasesAdapter extends NormalListAdapter<Cases>{
private ViewHolder viewHolder = null;
private Context mCtc;
private static class ViewHolder {
public ImageView aImg;
public TextView aTitle;
public TextView aHits;
public TextView aTime;
}
public CasesAdapter(Context context, List<Cases> item) {
super(context, item);
// TODO Auto-generated constructor stub
mCtc = context;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
//判断试图是否为空
if (convertView==null) {
//如果试图为空的情况下,加载试图页面
convertView=inflater.inflate(R.layout.list_item_cases, null);
// 实例化 ViewHolder
viewHolder = new ViewHolder();
// 设置viewholder中元素对应的控件
viewHolder.aImg=(ImageView) convertView.findViewById(R.id.imgs);
viewHolder.aTitle=(TextView) convertView.findViewById(R.id.msg_title);
viewHolder.aHits=(TextView) convertView.findViewById(R.id.msg_hit);
viewHolder.aTime=(TextView) convertView.findViewById(R.id.msg_time);
convertView.setTag(viewHolder);
}
else {
viewHolder=(ViewHolder) convertView.getTag();
}
Cases cs=itemContent.get(position);
//设置控件绑定的数值
viewHolder.aTitle.setText(cs.getTitle());
viewHolder.aHits.setText(cs.getHits());
viewHolder.aTime.setText(cs.getAddtime());
// 网络异步加载
ImageLoader.getInstance().displayImage("http://192.168.2.26:8012"+cs.getFilename(),
viewHolder.aImg, Define.options1,
new AnimateFirstDisplayListener());
return null;//该处报错,引起异常
} }

Android开发报错系列(一),java.lang.NullPointerException,at android.widget.ListView.setupChild的更多相关文章

  1. Android编译报Errors running builder 'Android Pre Compiler' on project 'XXX' java.lang.NullPointerException

    编译android时,遇到报错:Errors occurred during the build.Errors running builder 'Android Pre Compiler' on pr ...

  2. java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

    严重性 代码 说明 项目 文件 行 禁止显示状态错误 xamarin java.lang.UnsupportedClassVersionError: com/android/dx/command/Ma ...

  3. CrashHandler: java.lang.NullPointerException

    08-29 20:33:47.305 20636-20636/com.tongyan.subway.inspect D/AndroidRuntime: Shutting down VM 08-29 2 ...

  4. java.lang.NullPointerException

    你妹的这是什么错误啊? Errors occurred during the build. Errors running builder 'Android Resource Manager' on p ...

  5. activity_main.xml: java.lang.NullPointerException

    1.错误描写叙述 eclipse.buildId=4.4.0.I20140606-1215 java.version=1.7.0_67 java.vendor=Oracle Corporation B ...

  6. Android Studio 首次安装报错 Java.lang.RuntimeException:java.lang.NullPointerException...错

    下次安装报:Java.lang.RuntimeException: java.lang.NullPointerException......错 只需在文件..\Android Studio\bin\i ...

  7. java ee开发报错

    七月 26, 2015 9:57:52 下午 org.apache.coyote.AbstractProtocol destroy信息: Destroying ProtocolHandler [&qu ...

  8. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.love5/com.example.love5.Main11Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.

    若有 java.lang.RuntimeException和 java.lang.NullPointerException: Attempt to invoke virtual method 'voi ...

  9. android studio: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution o

    今天在运行部署项目时logcat弹出下列错误: -- ::-/? E/Zygote: v2 -- ::-/? I/libpersona: KNOX_SDCARD checking this -- :: ...

随机推荐

  1. iOS 中KVC、KVO、NSNotification、delegate 总结及区别-b

    1.KVC,即是指 NSKeyValueCoding,一个非正式的Protocol,提供一种机制来间接访问对象的属性.而不是通过调用Setter.Getter方法访问.KVO 就是基于 KVC 实现的 ...

  2. JDK源码阅读(二) AbstractList

    package java.util; public abstract class AbstractList<E> extends AbstractCollection<E> i ...

  3. iOS:处理XML文件

    NSXMLParser是标准库类 Book.xml <?xml version="1.0" encoding="UTF-8"?> <!--Do ...

  4. 投稿前必备的cover letter

  5. Android假退出不是流氓行为

    转自Android假退出不是流氓行为 关于Android程序的退出,目前我们没有再用System.exit(0)或killProcess的机制而是直接用Activity.finish假退出了.因此在内 ...

  6. 用正则式判断URL是否合法-python

    import sys import re #Make sure we have a single URL argument. if len(sys.argv) != 2: print (sys.std ...

  7. lc面试准备:Invert Binary Tree

    1 题目 Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 接口: public TreeNod ...

  8. 关于The APR based Apache Tomcat Native library警告

    今天在Eclipse上配置Tomcat7,启动时看到如下警告信息: The APR based Apache Tomcat Native library which allows optimal pe ...

  9. codeforce --- 340D

    D. Bubble Sort Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...

  10. Unity Fresnel Hero(Dota2) Shader

    Shader "HeroShader" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _Rim ...