我試圖讓一個viewflipper翻轉。似乎在正常的活動中工作,但是當我把所有東西都變成碎片時,我一直在收到NPE。NullPointerException與setAnimationListener()在FragmentActivity
這裏是我的代碼:
Animation in, out;
ViewFlipper customActionBarFlipper;
MyFragmentActivity mfa = MyFragmentActivity.this;
Context ctx = mfa; //Originally I was using this context in the loadAnimation.
in = AnimationUtils.loadAnimation(getBaseContext(), R.anim.push_left_in_80);
out = AnimationUtils.loadAnimation(getBaseContext(), R.anim.push_left_out_80);
in.setAnimationListener(mfa);
out.setAnimationListener(mfa);
customActionBarFlipper.setInAnimation(in);
customActionBarFlipper.setOutAnimation(out);
我有一個很好的感覺,我只是忘記明顯,但睡眠不足是殺手。如果任何人都可以如此善良,並把我推向正確的方向,那將不勝感激。
如果你想看到更多的代碼,我會很樂意提供它。我認爲這應該夠了。具有腳蹼的佈局也是充氣的。
謝謝!
你能粘貼錯誤日誌嗎? – 2013-02-20 05:46:09
不需要! :)在通過我的代碼時發現問題,我在查找id之前曾經誇大了我需要的內容。腳在口中! – user1457114 2013-02-20 06:24:17