2011-12-28 79 views
9

如何在像這樣的動態壁紙中創建設置活動?如何爲Android動態壁紙創建設置活動

Example Picture

我已經建立了設置活動只用簡單的文字和麪臨的一些問題。 第一個問題是我無法使用佈局XML文件進行此活動。 第二:當我嘗試編程構建該活動時,我無法將目錄設置爲系統圖標(drawable/ic_menu_more)。 另外我將需要使用SeekBar。

我會很高興,如果你幫我=)

+1

有關於這個問題上developer.android一章:http://developer.android.com/guide/topics/ui/settings。 HTML – Warpzit 2013-06-25 09:24:55

回答

1

的LiveWallpaper例在Android開發人員網站經歷正是: http://developer.android.com/resources/samples/CubeLiveWallpaper/index.html

更具體地說: 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) { 
} 
} 
7

對於使用系統圖標:

<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"/>