cannot resolve symbol OnClickListener while making a button to navigate in Android Studio -


i'm trying make simple button switches between 2 activites i'm having several problems.

my code entire mainactivity follows:

 package com.example.project.arithmeticalarm;  import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.button; import android.view.view; import android.view.view.onclicklistener;   public class mainactivity extends actionbaractivity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main); }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_main, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();      //noinspection simplifiableifstatement     if (id == r.id.action_settings) {         return true;     }      return super.onoptionsitemselected(item); }  button newalarm= (button)findviewbyid(r.id.newalarm); newalarm.setonclicklistener(new onclicklistener);{     public void onclick(view v){         startactivity(new intent(mainactivity.this, createalarm.class));     } }); 

}

everything except button text @ end created default havent touched that, afaik should working. problems i'm having i'm getting "cannot resolve symbol onclicklistener" error, , "cannot resolve symbol v", various squiggly red lines around v , on final closing bracket.

please driving me crazy.

write

button newalarm= (button)findviewbyid(r.id.newalarm); newalarm.setonclicklistener(new view.onclicklistener){     @override     public void onclick(view v){         startactivity(new intent(mainactivity.this, createalarm.class));     } }); 

inside method such in oncreate instead of class,because must initialise view in methods.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -