2013-05-19 4 views
0

나는 여전히 문제가 신체 어떤 도움 ?? 제발 시간이 없어요. Tommorow는 나의 마지막 졸업 프로젝트 프로젝트입니다. android에서 imageView로 런타임 오류를 해결하는 방법

(java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.assfar/com.example.assfar.hotel.Hotel_Details}: java.lang.NullPointerException 

내가 당신의 매니페스트에 활동을 등록했는지 확인하기 위해

package com.example.assfar.hotel; 

import android.app.Activity; 
import android.content.Intent; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.graphics.Bitmap; 
import android.graphics.BitmapFactory; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.ImageView; 
import android.widget.TextView; 

import com.example.assfar.R; 
import com.example.assfar.database.DBHelper; 
import com.example.assfar.offers.Customer_Info; 


public class Hotel_Details extends Activity{ 

    private DBHelper dataBase; 
    private ImageView imgv; 
    private TextView textView; 
    private TextView textView2; 
    private TextView textView3; 
    private Cursor cursor; 
    private String price; 
    private String hotelDesc; 
    private int idValue; 
    private byte [] imgByte; 


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

     textView = (TextView)findViewById(R.id.hotel_name); 
     textView2 = (TextView)findViewById(R.id.hotel_desc); 
     textView3 = (TextView)findViewById(R.id.hotel_price); 

     imgv = (ImageView)findViewById(R.id.hotel_image); 
     imgv.setImageDrawable(null); 


     Intent i= getIntent(); 
     // getting attached intent data 
     String item = i.getStringExtra("selected Item"); 
     int id = i.getIntExtra("hotel_id", 1); 


     // displaying selected product name 
      textView.setText(item); 

     imgByte= null; 

     dataBase= DBHelper.instance(); 
     SQLiteDatabase db= dataBase.getWritableDatabase(); 

     cursor= db.rawQuery("select * from hotel_reservation", null); 

     if(cursor!=null) { 
      if(cursor.moveToFirst()); 
      { 
       do 
       { 

       price = cursor.getString(cursor.getColumnIndex("price")); 
       idValue= cursor.getInt(cursor.getColumnIndex("ReservationID")); 
       hotelDesc= cursor.getString(cursor.getColumnIndex("hotel_Description"));             
       imgByte= cursor.getBlob(cursor.getColumnIndex("hotel_photo")); 
       Bitmap bmp = BitmapFactory.decodeByteArray(imgByte,0,imgByte.length); 

        if(idValue==id){ 

         textView2.setText("\n"+hotelDesc); 
         imgv.setImageBitmap(bmp); 
         } 

       } while(cursor.moveToNext()); 
      } 
     } 


     Button butt_reserve= (Button)findViewById(R.id.reserve); 
     butt_reserve.setOnClickListener(new OnClickListener(){ 

      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Hotel_Details.this,Customer_Info.class); 
       startActivity(i);      
     } 

     }); 

     } 
} 

로그 캣

05-19 16:53:32.411: E/AndroidRuntime(3661): FATAL EXCEPTION: main 
    05-19 16:53:32.411: E/AndroidRuntime(3661): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.assfar/com.example.assfar.hotel.Hotel_Details}: java.lang.NullPointerException 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.os.Handler.dispatchMessage(Handler.java:99) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.os.Looper.loop(Looper.java:137) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread.main(ActivityThread.java:5041) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at java.lang.reflect.Method.invokeNative(Native Method) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at java.lang.reflect.Method.invoke(Method.java:511) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at dalvik.system.NativeStart.main(Native Method) 
    05-19 16:53:32.411: E/AndroidRuntime(3661): Caused by: java.lang.NullPointerException 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at com.example.assfar.hotel.Hotel_Details.onCreate(Hotel_Details.java:74) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.Activity.performCreate(Activity.java:5104) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
    05-19 16:53:32.411: E/AndroidRuntime(3661):  ... 11 more 
+0

전체 logcat 게시 – Pragnani

+0

디버그하고 db의 인스턴스를 가져 오는지 확인하십시오! – Daniel

+0

나는 db의 인스턴스를 가지고 있습니다. 나는 이미지없이 코드를 시도했다. 그 코드는 보통 – user2327501

답변

0

확인 시작 활동 런타임 오류가 발생했습니다. 이것이 바로 이런 종류의 오류의 가장 일반적인 원인입니다.

+1

이다. 이것은 분명히 코멘트가되어야한다. – Daniel

+1

@ 대니얼이 의견을 동의했다. 그리고 그는 NP가 아닌 activitynotfound 예외를 얻고있다. –

+0

활동이 매니페스트 파일에 등록되었습니다. – user2327501

관련 문제