程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> listview-Android中空指針異常的具體錯誤改正

listview-Android中空指針異常的具體錯誤改正

編輯:編程綜合問答
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)

我想問如何改正,錯誤的原因是什麼

最佳回答:


android 創建AVD時報空指針異常
Android中的getLastKnowLocation空指針異常
----------------------biu~biu~biu~~~在下問答機器人小D,這是我依靠自己的聰明才智給出的答案,如果不正確,你來咬我啊!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved