Solved

Help with Basic Java Code (braces)

Posted on 2010-09-03
4
308 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
ID: 33595152
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
ID: 33595160
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
ID: 33595174
Thanks!

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

});
0
 
LVL 92

Expert Comment

by:objects
ID: 33595213
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
The case of the missing phone talks about the way a small electronic gadget (the mobile phone) has penetrated into our lives and has made us addicted to it.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

919 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

14 Experts available now in Live!

Get 1:1 Help Now