Solved

Help with Basic Java Code (braces)

Posted on 2010-09-03
4
304 Views
Last Modified: 2013-11-23
Hi There,

Google Android basic development

For the life of me i can't get the braces to close properly in this code, can someone please help and show how the braces should be closed.

Thanks
package com.button;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;


public class button extends Activity {
	Button mybutton;
	TextView mylabel;
	WebView mwebview;
    /** Called when the activity is first created. */
    @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
     
       
   mybutton.setOnClickListener(new View.OnClickListener(){
        
   
      public void onClick(View v){
        		 mwebview = (WebView) findViewById(R.id.webview);
        		    mwebview.getSettings().setJavaScriptEnabled(true);
        		    mwebview.loadUrl("http://www.google.com");
      
      			}			
   }
   

Open in new window

                     
              
0
Comment
Question by:auschoc
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
Comment Utility
public class button extends Activity {
      Button mybutton;
      TextView mylabel;
      WebView mwebview;

      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            mybutton.setOnClickListener(new View.OnClickListener() {

                  public void onClick(View v) {
                        mwebview = (WebView) findViewById(R.id.webview);
                        mwebview.getSettings().setJavaScriptEnabled(true);
                        mwebview.loadUrl("http://www.google.com");

                  }
            });

      }
}
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
Comment Utility
try,
package com.button;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;


public class button extends Activity {
		Button mybutton;
		TextView mylabel;
		WebView mwebview;

		/** Called when the activity is first created. */
	   @Override
	   public void onCreate(Bundle savedInstanceState) {
		   super.onCreate(savedInstanceState);
		   setContentView(R.layout.main);
     
       
	   mybutton.setOnClickListener(new View.OnClickListener(){			
	   
			public void onClick(View v){
						 mwebview = (WebView) findViewById(R.id.webview);
							mwebview.getSettings().setJavaScriptEnabled(true);
							mwebview.loadUrl("http://www.google.com");
			  
			}			
	   	   
		}
   
	 }
}

Open in new window

0
 

Author Closing Comment

by:auschoc
Comment Utility
Thanks!

could you possibly give me some advice when the following brace is needed

});
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
following marks where they were opened

            mybutton.setOnClickListener1(new View.OnClickListener() 2{

                  public void onClick(View v) {
                        mwebview = (WebView) findViewById(R.id.webview);
                        mwebview.getSettings().setJavaScriptEnabled(true);
                        mwebview.loadUrl("http://www.google.com");

                  }
            }2)1;
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now