views:

53

answers:

1

Well, I'm trying to follow the tutorial from http://rapidandroid.org/wiki/Graphing. But I found a problem just in the first part of it. I'll describe the problem here, I just cannot understand how this could be wrong, it's pretty simple stuff. What am I doing wrong here?

First I created a xml file called statistics.xml, in it among other things I put this code:

<WebView android:id="@+id/webview" android:layout_height="fill_parent"
    android:layout_width="fill_parent"/>

Now in the activity that is supposed to display this webview I'm doing this:

public class DisplayStatistics extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
        WebView wv = (WebView) findViewById(R.id.webview);

The problem arises here, as I seem to be getting null for wv whenever I test for it. Which means of course that findViewById(R.id.webview) couldn't find the view. But again, what am I doing wrong??

Of course I know I could also instantiate the webview directly from code without the need to specify it from the xml, but I was just wondering what was wrong about this way of doing it.

Just in case I also added the following line in my android manifest file:

<uses-permission android:name="android.permission.INTERNET" />

I'm not really sure if it's necessary for displaying the webview (I think not) but I just put it there to see if that was the problem, and it turned out it isn't.

Thanks

Nelson

+1  A: 

Should be setContentView(R.layout.statistics);.

alex