2011-03-16 81 views
0

我有一个崩溃: 错误/ AndroidRuntime(27007):致命异常:主03-15 18:29:04.967:错误/ AndroidRuntime(27007):java.lang.RuntimeException:无法销毁活动{com.TravelTop/com.TravelTop.Ego}:java.lang.NullPointerException我的应用程序崩溃

这是第一个活动的onCreate,当你按下按钮(fromButton)时,将调用其他活动并期望找回找回当国家

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.home); 

    // final int recquestCode = 0; 
    final Button btnCountryfrom = (Button) findViewById(R.id.fromButton); 
    btnCountryfrom.setOnClickListener(new OnClickListener() 
    { 

     public void onClick(View v) 
     { 


      Intent pingIntent = new Intent(getApplicationContext(),CountryView.class); 
      pingIntent.putExtra("btnText", " "); 
      pingIntent.setClass(TravelPharmacy.this, CountryView.class); 
      startActivityForResult(pingIntent, RECEIVE_MESSAGE); 
      Log.i("tag for easy filter in logcat 6","I am Working!!!"); 
      ButtonFromPressed=true; 

     } 



    }); 

}

名称国家的名称,在其他活动覆盖 onActivityResult来选择和按钮

 @Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{ 
    super.onActivityResult(requestCode, resultCode, data); 

    Button btnCountryfrom = (Button) findViewById(R.id.fromButton); 


     CharSequence seq = data.getCharSequenceExtra("response"); 
     btnCountryfrom.setText(seq); 
     ButtonFromPressed=false; 



    } 

}

我的第二个活动的OnCreate中设置的国家的名字

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.country); 

    mListUsers = getCountry(); 
    lvUsers = (ListView) findViewById(R.id.countrylistView); 
    lvUsers.setAdapter(new ListAdapter(this, R.id.countrylistView, mListUsers)); 



    lvUsers.setOnItemClickListener(new OnItemClickListener() 
    { 

     public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
     { 



      Intent pongIntent = new Intent(); 

      Log.i("tag for easy filter in logcat 1", "information you provide"); 

      Log.i("tag for easy filter in logcat 2",mListUsers.get(position).pays); 

      pongIntent.putExtra("response",mListUsers.get(position).pays); 
      setResult(Activity.RESULT_OK,pongIntent); 

      finish(); 
      Log.i("tag for easy filter in logcat 3",mListUsers.get(position).pays); 



     } 
    }); 

} 

我将感谢帮助!

谢谢!

+1

请发布一些您认为会导致此问题的代码。 – Chris

回答

0

看起来像空指针引用(从Java API文档)

“当应用程序试图在需要对象的地方使用null时,抛出该异常。......”

这是很难说没有看到代码更多。