0
嗨我是一個初學者的android操作系統編程,我陷入了一個問題,我無法弄清楚如何做一個動態的背景,基於計時器(說每10秒一個背景變化到另一個)我有一些代碼,但它有錯誤出現,這裏有一個例子:基於定時器(線性佈局)的動態背景,如何?
private static final long GET_DATA_INTERVAL = 10000;
int images[] = {R.drawable.smothie1,R.drawable.omletherb1};
int index = 0;
ImageView img;
Handler hand = new Handler();
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
LinearLayout layout= (LinearLayout)findViewById(R.id.LinearView1);
hand.postDelayed(run, GET_DATA_INTERVAL);
}
Runnable run = new Runnable() {
public void run() {
layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);
if (index == images.length)
index = 0;
hand.postDelayed(run, GET_DATA_INTERVAL);
任何幫助將大大apprieciated:d感謝
編輯:我得到的錯誤是在這條線:
layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);
它說:
-layout不能得到解決
-the方法getDrawable(INT)是未定義的類型對象
此錯誤:
layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);
它說即:
-layout無法解析
-the方法getDrawable(INT)是未定義的類型對象
請幫助:)
什麼錯誤到底是什麼? – Staven
請仔細閱讀下面的內容:D我把它作爲一個aswer,這似乎不接受代碼;) – Bercik
@Albert:如果你有額外的信息添加到你的問題,請編輯你的問題,而不是添加一個答案。你添加的內容不是'答案',因爲它不能回答你的問題。 –