2012-03-17 83 views
0

如果我想在程序中添加遏制繼承。它顯示了異常並要求強制殺人。任何人都可以解釋我爲什麼?如果我沒有正確使用,那麼請向我推薦一段代碼。使用遏制繼承的動畫

public class SongsActivity extends Activity{ 

    DemoView demoview ; 
    FinalView finalview; 
    LayoutAnimationController c; 
    /// containment inherttance using above 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 

     boolean first=true; 
     boolean sec=false; 
     demoview = new DemoView(this); 
     finalview = new FinalView(this); 

     for(int i=1;i>0;i++) 
     { 
      if (first==true||sec==false) 
      { 

       setContentView(finalview); 
       c.setDelay(1000);//containment inheritance using . 
       first=false; 
       sec=true; 
       break; 
      }else if(first==false||sec==true) 
      { 

       c.setDelay(1000); 
       first=true; 
       sec=true; 
      }else if(first==true||sec==true) 
      { 
       setContentView(demoview); 
       first=false; 
       sec=false; 
      }else 
      { 
       setContentView(demoview); 
       first=false; 
       sec=false; 
      } 
     } 
    } 

回答

0

不知道你尋找什麼,但對於力閉合的原因是,你宣佈一個LayoutAnimationController c;,但你永遠不分配一個值c,你只是想用它(c.setDelay())它會拋出一個空指針異常並導致應用程序崩潰。

+0

確定初始化後,它也不工作,它正在顯示進程意外停止。 – Ashishsingh 2012-03-17 19:07:17