gpt4 book ai didi

java - 为什么壁纸设置有异常错误?

转载 作者:行者123 更新时间:2023-11-30 04:23:10 24 4
gpt4 key购买 nike

我为 android 制作壁纸但遇到问题。当我点击设置按钮时,我看到:

01-22 11:50:47.579: E/AndroidRuntime(18421): FATAL EXCEPTION: main
01-22 11:50:47.579: E/AndroidRuntime(18421): java.lang.IllegalStateException: Could not execute method of the activity
01-22 11:50:47.579: E/AndroidRuntime(18421): at android.view.View$1.onClick(View.java:2154)
01-22 11:50:47.579: E/AndroidRuntime(18421): at android.view.View.performClick(View.java:2538)
...

我的代码:LiveWallpaperSettings.java:

package com.samples;

import android.os.Bundle;
import android.preference.PreferenceActivity;

public class LiveWallpaperSettings extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.wallpaper_settings);
}
}

wallpaper_settings.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
android:title="@string/wallpaper_label">
<PreferenceCategory android:title="General">
<CheckBoxPreference
android:title="Pref01 title"
android:summary="Pref01 summary"
android:key="pref01"
android:defaultValue="true"
/>
</PreferenceCategory>
</PreferenceScreen>

墙纸.xml:

<?xml version="1.0" encoding="UTF-8"?>
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="@drawable/icon"
android:description="@string/wallpaper_description"
android:settingsActivity="com.sample.LiveWallpaperSettings"/>

list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samples"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<service
android:name=".LiveWallpaperService"
...

<intent-filter>
...
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>

<activity
android:label="@string/wallpaper_label"
android:name=".LiveWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon="@drawable/icon">
</activity>
</application>
</manifest>

LiveWallpaperService 不使用任何首选项。我忘了写什么?请帮忙!

最佳答案

wallpaper.xml 上的包名称错误:

android:settingsActivity="com.sampleS.LiveWallpaperSettings"

关于java - 为什么壁纸设置有异常错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8959844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com