2013-12-08 32 views
1
public boolean onTouch(View v, MotionEvent event) { 

    final int DELAY = 100; 

    if(event.getAction() == MotionEvent.ACTION_UP) { 


     RelativeLayout fondo = (RelativeLayout) findViewById(R.id.background); 

     ColorDrawable f = new ColorDrawable(0xff00ff00); 
     ColorDrawable f2 = new ColorDrawable(0xffff0000); 
     ColorDrawable f3 = new ColorDrawable(0xff0000ff); 
     ColorDrawable f4 = new ColorDrawable(0xff0000ff); 

     AnimationDrawable a = new AnimationDrawable(); 
     a.addFrame(f, DELAY); 
     a.addFrame(f2, DELAY); 
     a.addFrame(f3, DELAY); 
     a.addFrame(f4, DELAY); 
     a.setOneShot(false); 

     fondo.setBackgroundDrawable(a); // This method is deprecated in API 16 
     // fondo.setBackground(a); // Use this method if you're using API 16 
     a.start(); 
    } 
    return true; 
} 

我想代替上述ontouch布爾值,我的背景更改顏色時查看和不touch.like按按鈕轉到一個新的佈局,然後沒有觸摸屏幕開始閃爍如何將觸摸布爾值更改爲像查看

+0

您的問題不清楚......您想要執行一次什麼操作? – Massimo

+0

好吧,其實我想換成觸摸,我不想觸摸屏幕,我想打開一個佈局,看到我的背景閃爍,它只是碰巧鍛煉出那種方式, –

回答

1

仍然需要更清楚一點,以幫助我們,並不完全確定你正在嘗試做什麼。

如果我理解正確,你想按下一個按鈕,然後打開屏幕閃爍的新佈局?

+0

你是男人! –

+0

我建議你做的是這樣的:http://stackoverflow.com/questions/12810705/how-do-i-make-a-layout-background-flashing-in-android?rq=1 – Bedimindtricks

+0

我的想法是從那裏,我正在尋找的東西,雖然正如我所說,我不想觸摸屏幕 –