Discussion Forums  >  Status Bar, Navigation Bar

Replies: 6    Views: 233

CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
01/25/13 07:28 PM (11 years ago)

Im stuck on these buttons

I can't figure out how to get these errors,I've tried cleaning up the document but the errors remains. Can someone point me in the right direction. "Beverage" is a java class file as is MainActivity These are errors I'm getting: "Multiple markers at this line - myButton cannot be resolved - The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View)" ---------------------------------------------------- package starbuckrecipes.com; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class Beverage extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button mybutton = (Button) findViewById(R.id.button1); myButton.setOnClickListener(new OnClickListener(){ public void OnClick(View v){ Intent nextIntent = new Intent(Beverage.this, MainActivity.class); Beverage.this.startActivity(nextIntent); } }); }
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
01/25/13 07:33 PM (11 years ago)
I'm trying to make a new screen appear when a button is clicked on the main activity screen.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/26/13 03:36 AM (11 years ago)
I'm a little confused; there isn't much in BT that worries about code... Are you talking about BT Screens, or are you customizing something...? Cheers! -- Smug
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
01/26/13 07:40 AM (11 years ago)
Hey @CMCOFFEe, First: "myButton cannot be resolved" Call your button after "public class Beverage extends Activity {" like this: Button myButton; and that will take care of that one. Second: "The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View)" " Did you paste that code in? To be implemented you have to call it like this in the beginning: "public class Beverage extends Activity implements onClickListener{" with out the quotes...then highlight onClickListener and click on the import then go over to Beverage and click on add the inherited method. Hope this helps, LA
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
01/26/13 09:41 AM (11 years ago)
I smell BTU Android Learning Path 3 here- Just rewatched that multiple time recently to get my Android button working. Is this where you are working from?
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
01/26/13 11:22 AM (11 years ago)
@atrain 53 yes I got this from. @smugwimp I wanted try from scratch bit its bwleen years since I worked with java.Ive bought every android and java book to help me as well as phonegap. After taking a break I realized I didnt download the api 8 sdk and the new adt bundle on android developer site is a lil different since it has the most recend android sdk and eclipse updated. @LA Ive seen some of the similar codes when working with one of my buzztouch source codes.I couldnt get it because I messwd up eclipse where it had x's in the classpath and package fikes and package didnt show up.Ive erased everything and reinstalled eclipse tostart ovet.I will try your suggestions.they make sense Thank you all for the help
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
01/26/13 11:27 AM (11 years ago)
@CMCOFFEE, If you need any more help just let me know. The best book is here on the forums, how to section, and the Learning Path and they are all free. LA
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.