2011-03-15 79 views
1

CustomDialogExample.java顯示java.lang.NullPointerException

public class CustomDialogExample extends Activity { 
    /** Called when the activity is first created. */ 


     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      /** Display Custom Dialog */ 
      CustomizeDialog customizeDialog = new CustomizeDialog(this); 
      customizeDialog.show(); 
     } 
    } 

CustomizeDialog.java

public class CustomizeDialog extends Dialog implements OnClickListener { 
Button okButton; 

public CustomizeDialog(Context context) { 
super(context); 
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */ 
requestWindowFeature(Window.FEATURE_NO_TITLE); 
/** Design the dialog in main.xml file */ 
setContentView(R.layout.main1); 
okButton = (Button) findViewById(R.id.OkButton); 
okButton.setOnClickListener(this); 
} 


@Override 
public void onClick(View v) { 
/** When OK Button is clicked, dismiss the dialog */ 
if (v == okButton) 
dismiss(); 
} 

} 

這是我的活動代碼,而我想從服務呼叫....

回答

0

您應該在AndroidManifest.xml中提到CustomDialogExample活動,如下所示:

<activity android:name=".CustomDialogExample" android:label="Dialog Example" 
        android:theme="@android:style/Theme.NoTitleBar" /> 
+0

@Vladimir我已經寫過那裏了......但它給出了同樣的錯誤... – Smith 2011-03-15 13:18:27

+0

請顯示堆棧跟蹤。 – 2011-03-15 13:57:45

+0

@vladimir我沒有得到!!我應該告訴你我的整個應用程序流程還是什麼?請告訴我...... – Smith 2011-03-16 04:38:56

相關問題