Android The following classes could not be instantiated

写第三方控件或者查看第三方控件时,经常出现一下的错误以至于eclipse预览不了控件
The following classes could not be instantiated:
- cn.edu.wust.hospital.widget.MyActionBar (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

此时仔细查看出错的代码,然后用
if (!isInEditMode()) {
出错的代码
}
包裹之即可

if (!isInEditMode()) {
    backImgView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            basedActivity.finish();
        }
    });
}

你可能感兴趣的:(Android The following classes could not be instantiated)