[英]How to create a settings activity for Android Live Wallpaper
如何在這樣的動態壁紙中創建設置活動?
我只使用簡單的文本構建了設置活動,並遇到了一些問題。 第一個問題是我無法使用布局XML文件進行此活動。 第二種:當我嘗試構建該活動時,我無法將目錄設置為系統圖標( drawable/ic_menu_more
)。 另外我需要使用SeekBar。
我會很高興,如果你幫助我=)
使用系統圖標:
<service android:name="com.livewallpaper.warm.LiveWallpaper"
android:label="@string/app_name"
android:icon="@drawable/ic_menu_more">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="@xml/livewallpaper" />
</service>
在XML-livewallpaper.xml中:
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.livewallpaper.warm.LiveWallpaperSettings"
android:thumbnail="@drawable/ic_menu_more"/>
Android Dev網站上的LiveWallpaper示例(現已緩存)完全符合以下要求: http : //web.archive.org/web/20111229075658/http : //developer.android.com/resources/samples/CubeLiveWallpaper/index.html
更具體地說: http : //web.archive.org/web/20120104043512/http : //developer.android.com/resources/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2Settings.html
簡而言之:
public class CubeWallpaper2Settings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(
CubeWallpaper2.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.cube2_settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
this);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.