In my onCreate, I have:
MyWebView webView = new MyWebView(this, null);
webView = (MyWebView) findViewById(R.id.pdf);
The custom webview class inside the Deal class:
public class MyWebView extends WebView {
Paint p = new Paint();
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
p.setColor (Color.RED);
canvas.drawLine (20, 10, 300, 400, p);
}
}
The XML:
<im.magic.dealpdf.Deal.MyWebView
android:id="@+id/pdf"
android:layout_weight="0.4"
android:layout_margin="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"/>
The error states it didn't find the class im.magic.dealpdf.Deal.MyWebView. Why is the error coming up? Changing the xml to im.magic.dealpdf.Deal results in cannot be cast to android.view.View
Update: I think I need to extend View in my Deal class. But it already extends Activity