AnnBnnCnnD 2013-05-16 05:51 采纳率: 0%
浏览 3692
已采纳

应用报错fatal错误,强制关闭

LOGCAT 错误:

05-16 07:16:24.503: E/AndroidRuntime(17625): FATAL EXCEPTION: main
05-16 07:16:24.503: E/AndroidRuntime(17625): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fdc/com.example.fdc.Medical_Record}: java.lang.NullPointerException
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.os.Looper.loop(Looper.java:123)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread.main(ActivityThread.java:3687)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at java.lang.reflect.Method.invokeNative(Native Method)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at java.lang.reflect.Method.invoke(Method.java:507)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at dalvik.system.NativeStart.main(Native Method)
05-16 07:16:24.503: E/AndroidRuntime(17625): Caused by: java.lang.NullPointerException
05-16 07:16:24.503: E/AndroidRuntime(17625):    at com.example.fdc.Medical_Record.onCreate(Medical_Record.java:84)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 07:16:24.503: E/AndroidRuntime(17625):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-16 07:16:24.503: E/AndroidRuntime(17625):    ... 11 more

代码:

package com.example.fdc;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
public class Medical_Record extends Activity{
TextView Record1,
Record2,Record3,
Record4,Record5,Record6
,Record7,Record8,Record9,
Record10,Record11;
String array_record [];

String username ="";
String id="";
String pname="";
String prel="";
String paddress="";
String pno="";
String poffice="";
String pmobile="";
String pbirth="";
String pcomment="";
String pcomplain = "";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_medical__record);

  Record1 = (TextView) findViewById(R.id.precord1);
  Record2 = (TextView) findViewById(R.id.precord2);
  Record3 = (TextView) findViewById(R.id.precord3); 
  Record4 = (TextView) findViewById(R.id.precord4);
  Record5 = (TextView) findViewById(R.id.precord5);
  Record6 = (TextView) findViewById(R.id.precord6);
  Record7 = (TextView) findViewById(R.id.precord7);
  Record8 = (TextView) findViewById(R.id.precord8);
  Record9 = (TextView) findViewById(R.id.precord9);
  Record10 = (TextView) findViewById(R.id.precord10);



            Intent intent=getIntent();
        String message =intent.getStringExtra("values");
        if(message.contains(","))
        {
            array_record=message.split(",");


         username =array_record[0];
         id=array_record[1];
         pname=array_record[2];
         prel=array_record[3];
         paddress=array_record[4];
         pno=array_record[5];
         poffice=array_record[6];
         pmobile=array_record[7];
         pbirth=array_record[8];
         pcomment=array_record[9];
         pcomplain = array_record[10];



        Log.d("ijazzzz", prel);

        Record1.setText(username);
        Record2.setText(id);
        Record3.setText(pname);
        Record4.setText(prel);
        Record5.setText(paddress);
        Record6.setText(pno);
        Record7.setText(poffice);
        Record8.setText(pmobile);
        Record9.setText(pbirth);
        Record10.setText(pcomment);
        Record11.setText(pcomplain);
        }
        else

        {
            Log.d("ijazzzz", "sssssssssssssssss");
        }
        }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.medical__record, menu);
    return true;
}
}

调试代码并没有错误,获取数据来自HttpPost,并且将长数据分割后存储在字符串中。
最后在Textview中设置时报错了。

  • 写回答

2条回答 默认 最新

  • 小船哥说敏捷 2013-05-16 07:39
    关注

    自己要学会看log,Medical_Record.java:84行报空指针,你的Record11没有初始化

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题