2011-12-28 38 views
9

¿Cómo crear una actividad de configuración en un fondo de pantalla en vivo como este?Cómo crear una actividad de configuración para Android Live Wallpaper

Example Picture

he construido actividad ajustes sólo con un texto simple y enfrentado a algunos problemas. El primer problema es que no puedo usar el archivo XML de diseño para esta actividad. El segundo: no puedo configurar el directorio al ícono del sistema (drawable/ic_menu_more) cuando intento crear esa actividad programmly. También necesitaré usar SeekBar.

estaré muy contento, si me ayuda =)

+1

Hay un capítulo sobre este tema en developer.android: http://developer.android.com/guide/topics/ui/settings. html – Warpzit

Respuesta

1

El Ejemplo LiveWallpaper en el sitio Android Dev pasa por exactamente eso: http://developer.android.com/resources/samples/CubeLiveWallpaper/index.html

Más específicamente: http://developer.android.com/resources/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube2/CubeWallpaper2Settings.html

En pocas palabras :

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

Para usar el icono del sistema:

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

En 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"/> 
Cuestiones relacionadas