-5
我有一個程序,當我嘗試啓動它時,它崩潰。我真的不明白爲什麼,即使是Eclipse秀,也沒有錯誤。 我可以告訴你一個我認爲是問題的頁面的代碼。啓動時應用程序崩潰「不幸,已停止」
package ctect.android.maxipro;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class BasicScreenActivity extends Activity {
private Button butonul1;
private Button butonul2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic_screen);
butonul1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View currentView) {
// TODO Auto-generated method stub
butonul2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View currentView) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(currentView.getContext(), NeedForSpeedActivity.class);
startActivityForResult(myIntent, 0);
Intent myIntent2 = new Intent(currentView.getContext(), Fifa2012Activity.class);
startActivityForResult(myIntent2, 0);
}
});
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.basic_screen, menu);
return true;
}
}
如果有人理解,請幫助我。
'甚至Eclipse展示的沒有錯誤'請原諒我的直接和誠實,但你真的不明白爲什麼Eclipse不能告訴你錯誤只發生在運行時?在解決所有編譯時錯誤之前,不可能得到運行時錯誤,因爲在編譯之前甚至無法運行應用程序。如果Eclipse顯示運行時錯誤,那麼每個應用程序都是無錯誤的!所以人們可以找到你的錯誤,請從logcat發佈堆棧跟蹤。 – Simon
您是否考慮在尋求幫助之前讓您的問題中的代碼可讀。也請從logcat發佈日誌。 – Varun
**甚至Eclipse展示了沒有錯誤** - 但有一個原因稱爲「Eclipse」而不是「oracle」。 –