كيفية التقاط الاستثناءات الناتجة عن ملف تخطيط مشوه-XML؟
-
26-09-2019 - |
سؤال
public class MyActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//R.layout.main has an illegal element (e.g. no layout_height attribute)
//But no exception is thrown at this line.
setContentView(R.layout.main);
} //Exception will be thrown after this line. Where to catch it?
}
المحلول
هل أنت جاد؟ هذا النوع من الأشياء لا يمكن أن يكون فقط "تم اللحاق به"... يجب إصلاحها. فقط إصلاح ملف XML الخاص بك وهذا كل شيء ... ليس من المنطقي التقاط مثل الاستثناء ؛ ماذا ستفعل بعد اصطياده؟
لا تنتمي إلى StackOverflow