Solved

Help with Basic Java Code (braces)

Posted on 2010-09-03
4
312 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

806 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