我下载了 Airpush Bundle SDK 1.0,因为我想在我的应用中添加横幅广告。我将 sdk 导入到我的项目中,并将规则添加到我的 list 中。
但是,当我运行我的程序时,我没有看到任何广告。
每次在布局管理器中都显示“无法实例化”,如我上面的屏幕截图所示。
我尝试删除 google play 服务,然后将其重新加载到项目中,但没有任何改变。
这是错误消息的文本:
The following classes could not be instantiated:
- com.bplxjxdpse.achmyqxdlf225456.AdView (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
最佳答案
将此发送给他们的开发人员,他们应该跳过他们类(class)中的一些内容并为开发人员绘制一些内容以查看 editMode
是否处于 Activity 状态,就像错误所说的那样。除非您有权访问资源,否则您无能为力。
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
if (isInEditMode()) {
// This will be shown in XML layout design
Paint mTitlePaint = new Paint();
mTitlePaint.setColor(Color.BLACK);
mTitlePaint.setStyle(Paint.Style.FILL);
mTitlePaint.setAntiAlias(true);
mTitlePaint.setTextSize(40);
String mTitle = "Ad will appear here";
float xPos = ((getMeasuredWidth() - mTitlePaint.measureText(mTitle)) / 2.0f);
float yPos = (getMeasuredHeight() / 2.0f);
float titleHeight = Math.abs(mTitlePaint.descent() + mTitlePaint.ascent());
yPos += titleHeight / 2.0f;
canvas.drawText(mTitle, xPos, yPos, mTitlePaint);
}
}
关于java - 无法实例化 Airpush 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29688624/