好吧,我需要帮助添加设置以选择要显示的纹理 - 你应该能够明白我的意思,因为已经有两个设置。我有设置的 gui 以及我无法弄清楚如何实现它的活动。如果你能帮助我,我会在应用程序的设置和市场帖子中记入你的功劳。连同你的名字、网站或视频中我的 youtube 频道上的任何内容。可以在这里找到,youtube.com /motodroidhelpandinfo 。我有超过 1,200 名订阅者。提前致谢。
这是我的偏好活动:
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) {}
}
这是我在主要活动中实现它的尝试。请注意,我无法将相关的内容融入整个活动。此外,我希望设置在您可以看到的纹理之间进行更改。我也使用 andengine.org 作为主干。
@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) {}