LoginSignup
1
1

More than 5 years have passed since last update.

カスタムビューを使用時に、GraphicalLayoutでClassCastExceptionや”Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse”と出る場合の対処

Posted at

NumberPicker,DatePickerをSDKから抜いてきてアプリに組み込んでる時に遭遇。
実行するとちゃんと出る。

どうやらADTのバグらしい。
http://code.google.com/p/android/issues/detail?id=6894

仕方ないので、try~catchで囲み、必要ならnullチェックしましょう。

NumberPicker.java
        try{
            mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
            mIncrementButton.setOnClickListener(clickListener);
            mIncrementButton.setOnLongClickListener(longClickListener);
            mIncrementButton.setNumberPicker(this);
        }catch(ClassCastException issue6894){
            // ADTのバグで落ちるようなので無視
        }

        try{
            mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
            mDecrementButton.setOnClickListener(clickListener);
            mDecrementButton.setOnLongClickListener(longClickListener);
            mDecrementButton.setNumberPicker(this);
        }catch(ClassCastException issue6894){
            // ADTのバグで落ちるようなので無視
        }

        try{
            mText = (EditText) findViewById(R.id.timepicker_input);
            mText.setOnFocusChangeListener(focusListener);
            mText.setFilters(new InputFilter[] {inputFilter});
            mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
        }catch(ClassCastException issue6894){
            // ADTのバグで落ちるようなので無視
        }

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1