CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    [android]2simple App

    Anybody knows why this code won't compile?

    Code:
    package com.leebrainlow.tween;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    
    public class Main extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            final Button b = (Button) findViewById(R.id.button1);
            b.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View arg0) {
    				
    				Animation anim = AnimationUtils.loadAnimation(Main.this, R.anim.animation);
    				b.startAnimation(anim);
    				
    				
    			}
    		});
        }
    }

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: [android]2simple App

    What is the compiler error message?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    Re: [android]2simple App

    pic

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: [android]2simple App

    There's no visible class called OnClickListener.

    I've not used Android at all but from the error messages it looks like it was expecting an object of type View.OnClickListener
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    Re: [android]2simple App

    here are some options
    pic

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: [android]2simple App

    Did you try changing the type to the correct one by appending the "View."?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  7. #7
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    Re: [android]2simple App

    Where should i put it?

  8. #8
    Join Date
    Apr 2012
    Location
    Slovenia
    Posts
    259

    Re: [android]2simple App

    i just found an error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured