我一直在尋找答案,但大多數似乎指向getApplicationContext()問題,但我沒有使用getApplicationContext()。 基本上我試圖在啓動一個活動時打開一個彈出窗口,但是當活動開始時它強制關閉並出現上述錯誤。
代碼IM已經writen是:
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.installguides_menu);
setTitleFromActivityLabel(R.id.title_text);
btn_Back = (Button) findViewById(R.id.btn_Back);
btn_Back.setOnClickListener (btn_Back_onClick);
btn_Ubuntu10Guide = (Button) findViewById(R.id.btn_Ubuntu10Guide);
btn_Ubuntu12Guide = (Button) findViewById(R.id.btn_Ubuntu12Guide);
btn_BacktrackGuide = (Button) findViewById(R.id.btn_BacktrackGuide);
btn_DebianGuide = (Button) findViewById(R.id.btn_DebianGuide);
btn_Ubuntu10Guide .setOnClickListener (btn_Ubuntu10Guide_onClick);
btn_Ubuntu12Guide .setOnClickListener (btn_Ubuntu12Guide_onClick);
btn_BacktrackGuide .setOnClickListener (btn_BacktrackGuide_onClick);
btn_DebianGuide .setOnClickListener (btn_DebianGuide_onClick);
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.donation_popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
popupWindow.dismiss();
}});
popupWindow.showAsDropDown(btn_Ubuntu10Guide, 50, -30);
}
希望你們能幫助,尋找答案一直在找了幾個小時讓你我最後的希望!
發佈logcat會更好。 – 2012-07-16 05:06:36