0
我在我的應用中使用了HoloEveryWhere
。我也使用該庫作爲AlertDialog
。當我在仿真器上運行我的應用程序時,它在Android 2.x和4.x上運行良好,但如果我選擇Android 3(僅適用於Android 3,即使它在Android 3.1上運行正常),如果應用程序想要顯示AlertDialog
。是我的代碼中的問題?無法在模擬器上顯示AlertDialoge
android.view.LayoutInflater inflater(android.view.LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View vi = inflater.inflate(com.test.di.xml,
null);
new AlertDialog.Builder(this).setView(vi)
.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
contentValues = new ContentValues();
// tasks
}
}).setNegativeButton("Cancel", null).setTitle("title")
.show();
更新1: 如果我不使用HoloeveryWhere
庫,然後我不明白這些錯誤!
更新2: 而應用程序是在模擬器上運行的Android 3:
10-12 15:07:03.594: E/AndroidRuntime(479): FATAL EXCEPTION: main
10-12 15:07:03.594: E/AndroidRuntime(479): java.lang.IllegalStateException: Could not execute method of the activity
10-12 15:07:03.594: E/AndroidRuntime(479): at android.view.View$1.onClick(View.java:2704)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.view.View.performClick(View.java:3100)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.view.View$PerformClick.run(View.java:11644)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.os.Handler.handleCallback(Handler.java:587)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.os.Handler.dispatchMessage(Handler.java:92)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.os.Looper.loop(Looper.java:126)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.app.ActivityThread.main(ActivityThread.java:3997)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.reflect.Method.invoke(Method.java:491)
10-12 15:07:03.594: E/AndroidRuntime(479): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-12 15:07:03.594: E/AndroidRuntime(479): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-12 15:07:03.594: E/AndroidRuntime(479): at dalvik.system.NativeStart.main(Native Method)
10-12 15:07:03.594: E/AndroidRuntime(479): Caused by: java.lang.reflect.InvocationTargetException
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.reflect.Method.invoke(Method.java:491)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.view.View$1.onClick(View.java:2699)
10-12 15:07:03.594: E/AndroidRuntime(479): ... 11 more
10-12 15:07:03.594: E/AndroidRuntime(479): Caused by: java.lang.NoClassDefFoundError: android.view.accessibility.AccessibilityNodeInfo
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.Class.getDeclaredMethods(Native Method)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.ClassCache.getDeclaredMethods(ClassCache.java:140)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.Class.getDeclaredMethod(Class.java:725)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.LayoutInflater.rInflate(LayoutInflater.java:744)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.LayoutInflater.rInflate(LayoutInflater.java:734)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.LayoutInflater.rInflate(LayoutInflater.java:734)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:538)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:488)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.app.Dialog.requestDecorView(Dialog.java:155)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.app.Dialog.setContentView(Dialog.java:170)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.app.AlertDialog.installDecorView(AlertDialog.java:405)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.internal.AlertController.installContent(AlertController.java:474)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.app.AlertDialog.onCreate(AlertDialog.java:411)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.app.Dialog.dispatchOnCreate(Dialog.java:335)
10-12 15:07:03.594: E/AndroidRuntime(479): at android.app.Dialog.show(Dialog.java:248)
10-12 15:07:03.594: E/AndroidRuntime(479): at org.holoeverywhere.app.AlertDialog$Builder.show(AlertDialog.java:345)
10-12 15:07:03.594: E/AndroidRuntime(479): at com.test.HomeActivity.delayClicked(HomeActivity.java:353)
10-12 15:07:03.594: E/AndroidRuntime(479): ... 14 more
10-12 15:07:03.594: E/AndroidRuntime(479): Caused by: java.lang.ClassNotFoundException: android.view.accessibility.AccessibilityNodeInfo in loader dalvik.system.PathClassLoader[/data/app/com.test-1.apk]
10-12 15:07:03.594: E/AndroidRuntime(479): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.ClassLoader.loadClass(ClassLoader.java:548)
10-12 15:07:03.594: E/AndroidRuntime(479): at java.lang.ClassLoader.loadClass(ClassLoader.java:508)
10-12 15:07:03.594: E/AndroidRuntime(479): ... 31 more
,這裏的進口:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.holoeverywhere.app.AlertDialog;
import org.holoeverywhere.widget.SeekBar;
import org.holoeverywhere.widget.SeekBar.OnSeekBarChangeListener;
import org.holoeverywhere.widget.Toast;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Vibrator;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnLongClickListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
「我選擇的Android 3.0它得到,如果應用程序要顯示一個AlertDialog強制關閉」。你可以發佈相同的堆棧跟蹤嗎? – Raghunandan
@Raghunandan請參閱更新:) – Soheil
@Raghunandan現在! – Soheil