0

HoloEveryWhere在我的应用程序中使用。我也将该库用于AlertDialogs 。当我在模拟器上运行我的应用程序时,它在 Android 2.x 和 4.x 上运行良好,但如果我选择 Android 3(只有 Android 3,即使它在 Android 3.1 上运行良好),如果应用程序想要显示AlertDialog. 是我的代码的问题吗?

        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;
4

1 回答 1

1

改变这个

 android.view.LayoutInflater inflater(android.view.LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View vi = inflater.inflate(com.test.di.xml,
        null);

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View vi = inflater.inflate(R.layout.mylayout,
            null);

编辑:

    TextView tv = new TextView(this);
    tv.setText("Holo every where");
    Builder builder=   new org.holoeverywhere.app.AlertDialog.Builder(this);
    builder.setTheme(AlertDialog.THEME_HOLO_LIGHT);
    builder.setView(tv)
    .setPositiveButton("OK", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            // tasks
        }
    }).setNegativeButton("Cancel", null).setTitle("title");
    builder.show();

快照

在此处输入图像描述

于 2013-10-12T13:14:16.160 回答