标题:Android背景问题
取消只看楼主
云儿架起彩虹
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-4-2
结帖率:0
 问题点数:0 回复次数:0 
Android背景问题
Android开发中,我现在在写一个类似win8的假界面,当作练习,我想实现整个桌面屏幕背景图片每隔一段时间就自动切换一张,我现在的代码是这样的,但实现不了,请各位大神指教。
  /*
     * 背景切换类
     */
    public class ChangeBackgroundThread extends Thread{
        @Override
        public void run() {
            // TODO Auto-generated method stub
            super.run();
            int i=0;
            do{
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println("----> 切换");
                main_linear.setBackgroundDrawable
                (getResources().getDrawable(BackGroundDrawable.slideImage[i]));
               
                i++;
                if(i>BackGroundDrawable.slideImage.length){
                    i=0;
                }
            }while(i<=BackGroundDrawable.slideImage.length&& mclockThread.interrupted()==false);
        }
        
    }

public class BackGroundDrawable {
   
    public static int slideImage[]={
        R.drawable.main_background,
        R.drawable.backround1,
        R.drawable.background2,
        R.drawable.background3,
        R.drawable.background4,
        R.drawable.background5,
        R.drawable.background6,
        R.drawable.background7,
        R.drawable.background8,
        R.drawable.background9,
        R.drawable.background10,
        R.drawable.background12,
        R.drawable.background13,
        R.drawable.background16,
        R.drawable.background17,
        R.drawable.background18
    };
}
为什么会实现不了呢,调试的时候,根本就执行不了main_linear.setBackgroundDrawable
                (getResources().getDrawable(BackGroundDrawable.slideImage[i]));这句
搜索更多相关主题的帖子: Android 背景图片 public method 开发 
2014-04-02 09:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429545-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048583 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved