2011-12-28 50 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"/>