views:

142

answers:

1

Ok well I need help adding settings to choose which texture to show you should be able to tell what I mean because there are already two set up. i have the gui for the settings set up along with the activity I just can't figure out how to implement it. If you can help me I'll credit you in the app in the settings and the market post. Along with your name, website or, whatever on my youtube channel in a video. Which can be found here, youtube.com/motodroidhelpandinfo. I have over 1,200 subscribers. Thanks in advance.

Here's my preference Activity:

   package quotesandothers.livewallpaper.quotesandothers;

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

         public class Settings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener
 {  
@Override
protected void onCreate(Bundle icicle)
{
    super.onCreate(icicle);
    getPreferenceManager().setSharedPreferencesName(livewallpaper.PREFERENCES);
    addPreferencesFromResource(R.xml.wallpaper_settings);
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}

@Override
protected void onResume()
{
    super.onResume();
}

@Override
protected void onDestroy()
{
    getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    super.onDestroy();
}

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{

}
   }

And here's my attempt at implementing it in the main activity. Note I couldn't fit in the whole Activity just what is relevant. Also I want the setting to change between the to textures that you can see. Also I use andengine.org as the backbone.

@Override
public void onLoadResources() {

     preferences = PreferenceManager.getDefaultSharedPreferences(this);
        preferences.registerOnSharedPreferenceChangeListener(this);


this.mTexture = new Texture(2048, 2048, TextureOptions.DEFAULT);


    this.mParallaxLayerMid1 = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/middle1.png",0, 320);
    this.mParallaxLayerTop = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/top.png", 0, 0);
    this.mParallaxLayerTop2 = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/top2.png", 0, 173);
    this.mParallaxLayerMid2 = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/middle2.png",0, 450);
    this.mParallaxLayerLow1 = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/lower1.png", 200,574);
    this.mParallaxLayerLow2 = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxMotivationalTexture, this, "gfx/lower2.png", 0,740);
    this.mEngine.getTextureManager().loadTextures(this.mTexture,
            this.mAutoParallaxMotivationalTexture);

this.mTexture = new Texture(2048, 2048, TextureOptions.DEFAULT);

    this.mParallaxLayerTopInspired = TextureRegionFactory.createFromAsset(
            this.mAutoParallaxInspirationalTexture, this, "gfx/topinspired.png", 0, 0);

}

public void OnSharedPreferenceChanged(SharedPreferences prefs, String key) {
 }
A: 

Things look ok there.

There is only one difference with my app, which I based off the cube wallpaper example.

This line where you get the preferences looks different for me.

preferences = PreferenceManager.getDefaultSharedPreferences(this);

Mine:

preferences = myWallpaper.this.getSharedPreferences(SHARED_PREFS_NAME, 0);

Give it a try and see what happens.

DarthNoodles