不正な形式のレイアウトxmlファイルによって引き起こされた例外をキャッチするには?

StackOverflow https://stackoverflow.com/questions/3822149

質問

    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?
    }
役に立ちましたか?

解決

本気なの?物事のようなものは、「のcatched の」ちょうどすることはできません...彼らは固定されなければなりません。ただ、そのような例外としてキャッチしても意味がありません...あなたのXMLファイルを修正し、それはそれです。あなたはそれをキャッチした後に何をしますか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top