任何人都可以幫助我找出什麼可以是這個程序的問題。 在onCreate()方法中,findViewById()對於所有ID都返回null,這會在稍後導致空指針異常。我無法弄清楚爲什麼findViewById()找不到視圖。有什麼建議麼? 這是主代碼: public class MainActivity extends Activity {
ViewPager pager;
My
是否有可能在主要Java類中全局地使用findViewById獲取對XML元素(如按鈕)的引用? 我有這麼多的引用,我需要繼續多次調用它們,因爲我不能使用onCreate方法調用的引用。 private long mode;
private final Button playBtn = (Button)findViewById(R.id.playBtn);
private final Text