2012-05-06 9 views
0

코드 :안드로이드 앱 활동 오류

public class MainActivity extends Activity { 

    private ListView lv; 
    private CustomAdapter adapter; 
    private ArrayList<Event> fetch = new ArrayList<Event>(); 
    private Button button; 
    int counter = 0; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

      adapter = new CustomAdapter(MainActivity.this, R.id.listview,fetch); 
     lv.setAdapter(adapter); 
     button = (Button) findViewById(R.id.button); 
     button.setOnClickListener(new OnClickListener(){ 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       Event temp=new Event("Date","Details","GeoLocation","Location","EvtName"); 
       fetch.add(temp); 
       counter++; 
       adapter.notifyDataSetChanged(); 

      } }); 

    } 

} 

앱을 Unable to start Activity componentInfo 오류와 함께 실패합니다. Logcat은 :

05-06 12:56:34.248: E/AndroidRuntime(2215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nasotech/com.nasotech.MainActivity}: java.lang.NullPointerException 

어떻게 해결할 수 있습니까?

답변

3

먼저 ID로 같은

lv = (ListView)findViewById(R.id.listview); 
+0

감사의 친구를 목록보기를 찾을 수 .. :)의 내 실수 – Sathish

+1

@Sathish 그 경우 당신을 도움이 무엇인지, 대답을 받아 – thepoosh