如何捕捉引起的畸形布局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