我是學holoeverywhere庫>>https://github.com/Prototik/HoloEverywhere/ 我正在嘗試alertdialog,但我得到崩潰..AlertDialog Holoeverywhere崩潰?
這個錯誤..........
01-25 10:45:52.799: E/AndroidRuntime(12308): FATAL EXCEPTION: main
01-25 10:45:52.799: E/AndroidRuntime(12308): java.lang.NullPointerException
01-25 10:45:52.799: E/AndroidRuntime(12308): at org.holoeverywhere.widget.AlertController.setupContent(AlertController.java:681)
01-25 10:45:52.799: E/AndroidRuntime(12308): at org.holoeverywhere.widget.AlertController.setupView(AlertController.java:745)
01-25 10:45:52.799: E/AndroidRuntime(12308): at org.holoeverywhere.widget.AlertController.installContent(AlertController.java:469)
01-25 10:45:52.799: E/AndroidRuntime(12308): at org.holoeverywhere.app.AlertDialog.onCreate(AlertDialog.java:411)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.app.Dialog.dispatchOnCreate(Dialog.java:307)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.app.Dialog.show(Dialog.java:225)
01-25 10:45:52.799: E/AndroidRuntime(12308): at com.droidersuin.project.setting.SettingAppSystem.ClearChace(SettingAppSystem.java:196)
01-25 10:45:52.799: E/AndroidRuntime(12308): at com.droidersuin.project.setting.SettingAppSystem$2.onItemClick(SettingAppSystem.java:137)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.widget.ListView.performItemClick(ListView.java:3755)
01-25 10:45:52.799: E/AndroidRuntime(12308): at org.holoeverywhere.widget.ListView.performItemClick(ListView.java:635)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1964)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.os.Handler.handleCallback(Handler.java:587)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.os.Looper.loop(Looper.java:130)
01-25 10:45:52.799: E/AndroidRuntime(12308): at android.app.ActivityThread.main(ActivityThread.java:3687)
01-25 10:45:52.799: E/AndroidRuntime(12308): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 10:45:52.799: E/AndroidRuntime(12308): at java.lang.reflect.Method.invoke(Method.java:507)
01-25 10:45:52.799: E/AndroidRuntime(12308): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
01-25 10:45:52.799: E/AndroidRuntime(12308): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
01-25 10:45:52.799: E/AndroidRuntime(12308): at dalvik.system.NativeStart.main(Native Method)
這是我的代碼.........
import org.holoeverywhere.app.Activity;
import org.holoeverywhere.app.AlertDialog;
public class SettingAppSystem extends Activity {
//...
public void onCreate(Bundle savedInstanceState) {
//.....
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Delete Cache?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final ProgressDialog progressDialog = ProgressDialog.show(SettingAppSystem.this, "", "Delete Cache...");
new Thread() {
public void run() {
try {
ImageLoader imgLoader = new ImageLoader(getBaseContext());
ImageLoaderDetailImage imgLoaderDetailImage = new ImageLoaderDetailImage(getBaseContext());
imgLoader.clearCache();
imgLoaderDetailImage.clearCache();
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
progressDialog.dismiss();
Thread.currentThread().interrupt();
}
}.start();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
當我點擊logcat中,錯誤的是alert.show();,如何解決?對不起,我的英語
您是否在使用庫項目? – Piyush
yes holoeverywhere lib, –
必須檢查它是否在您的項目中顯示爲綠色標記。 – Piyush