java - Cannot find symbol id in button -


Hello, I am creating a simple push button in Android and this is my main system file

  Package dk.troll.android; Import android App Import android.content.Intent; Import android.net.Uri; Importroid.os.Bundle; Import android.widget.Button; Import android.view.View; Import android.view.View.OnClickListener; Override public class main activity activity (button button; @Create) overwrite public zeros (bundle saved instenstate) {super.naught (savedinstenstate); setContentView (R.layout.main); addListenerOnButton ();} Public Zero addListenerOnButton () {Button = (button) findViewById (R.id.button1); button.setOnClickListener (New OnClickListener) {@Override Public Zero onClick (see arg0) {intro browserIntent = new intent (Intent.ACTION_VIEW, Uri.parse ( "Http://www.troll.dk"); startActivity (browserIntent);}})}}  

and this is my XML file

 < Code> & lt; xml no Version = "1.0" encoding = "UTF-8"? & Gt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: Orientation = "Vertical" Android: Layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; TextView Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: text = "home epsom and so many other stuff" /> & Lt; Button Android: id = "@ + id / Button1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: text = "button - go troll" /> & Lt; / LinearLayout & gt;  

button = (button) findViewById (R.id.button1) on this line; Error can not be found I can not

r

Content of the class

generated, how can I fix the error?

Fist restart eclipse

Then do this:

1. Import R Class for your activity, import dk.troll.android.R;

2. Make sure that there is no error in all the files in the scripts, then try to clean the project from the clean project.

3. Build your project


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -