我做了一個自定義標題欄,我想要顯示在我的應用程序的所有活動。它完全在我的主要活動:自定義標題條碼打破onCreate()
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
但是我的主要活動調用另一個活動,當我嘗試做同樣的事情出現了失敗:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.layout_2);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
嘗試做findViewById ()崩潰和我包裹在一個try/catch一個看到發生了什麼事:
TextView tv1;
try {
tv1 = (TextView)findViewById(R.id.header);
}
catch (Exception e) {
Log.d("MyActivity2", "boom");
}
唯一的例外說 原因= ClassCastException異常 detailMessage = android.widget.RelativeLayout
我不知道這意味着什麼,並注:那裏有沒有問題如果我註釋掉requestWindowFeature()和getWindow()調用。
在此先感謝您對此的任何見解!
發佈完整的LogCat輸出。 – 2012-08-15 21:03:50