如何使复选框在动态壁纸Android应用程序中工作?

时间:2014-09-11 20:55:19

标签: android eclipse checkbox settings live-wallpaper

我的动态壁纸设置中有三个复选框,我需要弄清楚如何使它们工作,我想要例如checkbox1执行code1,checkbox2执行代码2,最后一个复选框执行code3:

code1:

private void incrementCounter() {


        if (mImagesArrayIndex >= mImagesArray.length-10) {
            mImagesArrayIndex = mImagesArray.length-10;}
            if (mImagesArrayIndex <10) {
                mImagesArrayIndex = 10;

码2:

private void incrementCounter() {


        if (mImagesArrayIndex >= mImagesArray.length-20) {
            mImagesArrayIndex = 0;}
            if (mImagesArrayIndex <0) {
                mImagesArrayIndex = mImagesArray.length-20;

            }       

            }   

CODE3:

 mImagesArrayIndex++;

code3(进入code1和code2),代码1,2,3都在CustomWallpaper.java中这就是全部,我已经设置了我的设置布局,它看起来像这样:

settings screen

1 个答案:

答案 0 :(得分:0)

溶液:

public void run() {

            SharedPreferences myPref = PreferenceManager.getDefaultSharedPreferences( CustomWallpaper.this);
            try {
                while (true) {
                    drawFrame();

                    if (myPref.getBoolean("lwp_o_scroll_lock_key",true)) 
                    incrementCounter1();
                    else 
                        incrementCounter2();
                    if (myPref.getBoolean("lwp_auto_animation_key",true))
                        mImagesArrayIndex++;
                    else
                        //
                //  if (myPref.getBoolean("lwp_auto_animation_key",true))
                        //incrementCounter2();

                    Thread.sleep(SeekBarPreference.mCurrentValue);
                }
            } catch (Exception e) {
                //
            }
        }