?
Solved

Help with Basic Java Code (braces)

Posted on 2010-09-03
4
Medium Priority
?
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
These days software publishers make it possible to move all the possible applications on smartphones, tablets, smartwatches, and more. Although behind every logic and decision is a gross doubt: how do they make it possible? In this blog post, we sha…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

649 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