setContentView failure with extended WebView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

setContentView failure with extended WebView

Postby deepdarksee » Fri Jan 23, 2009 10:48 pm

Hi,

I'm trying to create MyWebView by extending WebView. My issue is that when I setup MyWebView in the layout resource (by changing an existing reference to WebView to MyWebView in main.xml), my code fails at setContentView(R.layout.main). My code works with WebView.

Any suggestions? I think the issue is using non-built-in classes in a layout.

public class MyWebView extends WebView {
public MyWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyWebView(Context context) {
super(context);
}
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<MyWebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

Within OnCreate for the initial Activity of the App I have:
private static MyWebView mWebView;
setContentView(R.layout.main); <-- FAILURE HERE
mWebView = (MyWebView) findViewById(R.id.webview);

Thanks!
Spencer
deepdarksee
Freshman
Freshman
 
Posts: 2
Joined: Fri Dec 26, 2008 7:14 am

Top

Postby MrSnowflake » Mon Jan 26, 2009 10:30 pm

If you checked your log you would have seen that Android can't find your MyWebView because it has no package name before it...

How do you want to develop applications if you can't properly debug? Read some more about the Android log and debugging provided by the platform...
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests