开发者社区> 问答> 正文

Android中空指针异常的具体错误改正

import java.sql.Date;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;

import android.app.Activity;
 import android.app.Dialog;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.Gravity;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.WindowManager;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.SimpleAdapter;
 import android.widget.TextView;
 import android.widget.Toast;

public class MainActivity extends Activity {
private ImageView zy, ZyImge;
private TextView ZyLine, ZyLeade, ZyAb;
private String url;


private SimpleAdapter adapter;
private DBUtil dbUtil;
protected static final int MSG_OK = 0;
private ListView lv = null;
//private MyAdapter myAdapter = null;
private List<Card> list = new ArrayList<Card>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.adapter_item);
    zy = (ImageView) findViewById(R.id.zhengyou_list_img);
    ZyImge = (ImageView) findViewById(R.id.zhengyou_list_luxian);
    ZyLeade = (TextView) findViewById(R.id.zhengyou_list_name);
    ZyLine = (TextView) findViewById(R.id.zhengyou_list_title);
    ZyAb = (TextView) findViewById(R.id.zhengyou_list_time);

    final String ZyLines = getIntent().getExtras().getString("ZyLines");
    final String ZyImage = getIntent().getExtras().getString("ZyImage");
    final String ZyLeader = getIntent().getExtras().getString("ZyLeader");
    final String ZyAbs = getIntent().getExtras().getString("ZyAbs");

    ZyLine.setText(ZyLines);

    ZyLeade.setText(ZyLeader);
    ZyAb.setText(ZyAbs);
}
}

logcat中错误提示:

 Caused by: java.lang.NullPointerException
 07-24 09:00:34.209: E/AndroidRuntime(9339): at com.example.lianwang.MainActivity.onCreate(MainActivity.java:55)
 07-24 09:00:34.209: E/AndroidRuntime(9339): at android.app.Activity.performCreate(Activity.java:5122)
 07-24 09:00:34.209: E/AndroidRuntime(9339): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
 07-24 09:00:34.209: E/AndroidRuntime(9339): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)

我想问如何改正,错误的原因是什么

展开
收起
爵霸 2016-06-14 13:38:23 2465 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载