android - Syntax error on token(s) on line of code -


i'm getting error on 1 of lines of code can't seem find solution.

the error on line:

camerabutton.setonclicklistener(cameralistener); 

the error im getting "syntax error on token(s)

mainactivity

package com.example.triptych4;  import java.io.file;  import android.app.activity; import android.content.contentresolver; import android.content.context; import android.content.intent; import android.graphics.bitmap; import android.net.uri; import android.os.bundle; import android.os.environment; import android.provider.mediastore; import android.util.log; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.view.viewgroup; import android.widget.adapterview; import android.widget.baseadapter; import android.widget.button; import android.widget.gallery; import android.widget.imagebutton; import android.widget.imageview; import android.widget.toast;  public class mainactivity extends activity {       // label our logs "cameraapp3"     private static string logtag = "cameraapp3";     // tells camera take picture     private static int take_picture = 1;     // empty variable hold our image uri once store     private uri imageuri;      private integer[] pics = { r.drawable.android, r.drawable.android3d,           r.drawable.background3 };      private imageview imageview;       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          gallery gallery = (gallery) findviewbyid(r.id.gallery1);         //create adapter gallery         gallery.setadapter(new imageadapter(this));         imageview = (imageview) findviewbyid(r.id.imageview1);         gallery.setonitemclicklistener(new onitemclicklistener() {              @oveerride             public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) {                 toast.maketext(getapplicationcontext(), "pic:" + arg2, toast.length_short).show();                 imageview.setimageresource(pics[arg2]);             }            // button set in view         imagebutton camerabutton = (imagebutton)                 findviewbyid(r.id.button_camera);         // set listener on button         camerabutton.setonclicklistener(cameralistener);       }      // set new listener     private onclicklistener cameralistener = new onclicklistener() {         public void onclick(view v) {             // open camera , pass in current view             takephoto(v);         }     };      public void takephoto(view v) {         // tell phone want use camera         intent intent = new intent("android.media.action.image_capture");         // create new temp file called pic.jpg in "pictures" storage area of phone         file photo = new file(environment.getexternalstoragepublicdirectory(environment.directory_pictures), "pic.jpg");         // take return data , store in temp file "pic.jpg"         intent.putextra(mediastore.extra_output, uri.fromfile(photo));         // stor temp photo uri can find later         imageuri = uri.fromfile(photo);         // start camera         startactivityforresult(intent, take_picture);      }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }      public class imageadapter extends baseadapter{         private context context;         int imagebackground;          public imageadapter(context context){             this.context = context;         }          @override         public int getcount() {             // todo auto-generated method stub             return pics.length;         }          @override         public object getitem(int arg0) {             // todo auto-generated method stub             return arg0;         }          @override         public long getitemid(int arg0) {             // todo auto-generated method stub             return arg0;         }          @override         public view getview(int arg0, view arg1, viewgroup arg2) {             // todo auto-generated method stub             imageview imageview =new imageview(context);             imageview.setimageresource(pics[arg0]);             return imageview;         }     }      // override original activity result function     @override     public void onactivityresult(int requestcode, int resultcode, intent data) {         // call parent         super.onactivityresult(requestcode, resultcode, data);         switch(requestcode) {         // if requestcode equal our camera code (1) then...         case 1:             // if user took photo , selected photo use             if(resultcode == activity.result_ok) {                 // image uri earlier                 uri selectedimage = imageuri;                 // notify apps of changes make                 getcontentresolver().notifychange(selectedimage, null);                 // imageview set in our view earlier                 imagebutton imagebutton = (imagebutton)findviewbyid(r.id.button_camera);                 // create content resolver object allow access image file @ uri above                 contentresolver cr = getcontentresolver();                 // create empty bitmap object                 bitmap bitmap;                 try {                     // bitmap image uri using content resolver api image                     bitmap = android.provider.mediastore.images.media.getbitmap(cr, selectedimage);                     // set bitmap image view                     imagebutton.setimagebitmap(bitmap);                     // notify user                     toast.maketext(mainactivity.this, selectedimage.tostring(), toast.length_long).show();                 } catch(exception e) {                     // notify user                     toast.maketext(mainactivity.this, "failed load", toast.length_long).show();                     log.e(logtag, e.tostring());                 }             }         }       }    } 

you're missing braces , semicolons, , you've got @oveerride in there well.

try this, should compile:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      gallery gallery = (gallery) findviewbyid(r.id.gallery1);     //create adapter gallery     gallery.setadapter(new imageadapter(this));     imageview = (imageview) findviewbyid(r.id.imageview1);      gallery.setonitemclicklistener( new adapterview.onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view, int arg2, long arg3) {             toast.maketext(getapplicationcontext(), "pic:" + arg2, toast.length_short).show();             imageview.setimageresource(pics[arg2]);         }     });       // button set in view     imagebutton camerabutton = (imagebutton)             findviewbyid(r.id.button_camera);     // set listener on button     camerabutton.setonclicklistener(cameralistener);  } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -