在Choreographer的被跳的框架在改变的背景颜色

时间:2013-05-17 08:54:08

标签: android android-layout android-logcat android-4.0-ice-cream-sandwich android-2.3-gingerbread

嗨,我正在尝试构建一个应用程序,将屏幕转换为闪光灯或警笛声。在Galaxy gio上使用2.3安卓系统。在它上面的第二种颜色上贴上了设备。对于一个活动,logcat上的错误被跳过了太多的工作! 香港专业教育学院试图减少延迟,但它不会工作。只在4.0 + Android版本工作我该怎么办?

public class MainActivity extends Activity {

RelativeLayout soli;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //full screeen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //full screen
    setContentView(R.layout.activity_main);
    //brightness full
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 100 / 100.0f;
    //brightness full
    soli = (RelativeLayout) findViewById(R.id.soli);

}
public void soheil(){


    final RelativeLayout soli = ((RelativeLayout) findViewById(R.id.soli));
    ColorDrawable f = new ColorDrawable(0xff00ff00);
    ColorDrawable f2 = new ColorDrawable(0xffff0000);
    ColorDrawable f3 = new ColorDrawable(0xff0000ff);
    ColorDrawable f4 = new ColorDrawable(0xff0000ff);

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

    soli.setBackgroundDrawable(a); //  is deprecated  API 16
    // soli.setBackground(a); //  API 16
    a.start();




}
@Override
protected void onStart() {
super.onStart();soheil();

}
@Override
protected void onDestroy() {
super.onDestroy();

}
@Override
protected void onResume() {
super.onResume();

}
@Override
protected void onPause() {
super.onDestroy();

}
@Override
protected void onStop() {
super.onDestroy();

}

1 个答案:

答案 0 :(得分:0)

发现它没关系!这个答案可能对其他人有用。 我将所有图形都放在touchlistener事件上,一切都很顺利。