I'm trying to load a new webview after I click a button on my main
view, which loads on application start. My code compiles, and runs
without error, but when I press the button, I see the expected toast
message, but no webview. Instead, I only see a black screen. Can
anyone please tell me what I'm missing here? Alternatively, if a
different approach is a better implementation, please let me know!
Thanks! SJ

Main class code:
package com.example.MasterClass;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class MasterClass extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        firstView();
    }

    void firstView() {
      setContentView(R.layout.main);
        final ImageButton button = (ImageButton) findViewById
(R.id.android_button);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Perform action on clicks
                Toast.makeText(MasterClass.this, "Beep Bop",
Toast.LENGTH_SHORT).show();
                Intent i = new Intent(MasterClass.this,
SecondClass.class);
                startActivity(i);
            }
        });
    }
}

Second Class Code:

package com.example.MasterClass;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class SecondClass extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       WebView webview;
       webview = (WebView) findViewById(R.id.webview);
       webview.getSettings().setJavaScriptEnabled(true);
       webview.loadUrl("http://www.google.com";);
    }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to